Computer Knowledge

Java Core Classes and Threads

1,473 Questions

Java core classes and threads form the foundation of object oriented programming and are crucial for IT officer and programming exams. This includes concepts like string mutability, collections, and multithreading. Solve these questions to test your practical coding and theoretical knowledge.

String and StringBuffer classesThread execution methodsJava collections frameworkCharacter streams input outputVariable serialization rules

Java Core Classes and Threads Questions

Multiple choice
  1. Yes

  2. No

  3. Both (1) and (2)

  4. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Java objects are references to memory locations, not pointers in the C/C++ sense. Java does not allow direct pointer arithmetic.

Multiple choice
  1. SubList (int startindex, int endindex)

  2. PreviousIndex()

  3. NextIndex()

  4. HasPrevious()

  5. HasMiddle()

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This is the correct answer. SubList() method is present in the List Interface and it returns a sublist from the startindex to the endindex. So, this is the correct answer.

Multiple choice
  1. HashCode()

  2. HasNext()

  3. Next()

  4. AllRetain()

  5. EnsureCapacity()

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This is the correct answer. Hashcode() method is present in the Collection Interface. This function returns the hashcode for the collection. The hashcode of two objects must be same if the two objects are equal. So this is the correct answer.

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct answer because there are four constructors in the LinkedHashSet. These are :-LinkedHashSet () LinkedHashSet (c : Collection) LinkedHashSet (initialcapacity : int) LinkedHashSet (initialcapacity : int , loadfactor : float). So, this is the correct answer.