Computer Knowledge

Java Core Classes and Threads

1,935 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. Only A

  2. Only B

  3. Both A and B

  4. Neither A nor B

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

Both the statements are correct. The methods valueOf() and toString() belong to String class. The valueOf() method is a static method, so it is always called by using the class name String and the method toString() is overridden in wrapper classes, such as Integer and Double.

Multiple choice
  1. setLength()

  2. length()

  3. capacity()

  4. startWith()

  5. ensureCapacity()

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

This method is used to pre-allocate a space for a certain number of characters, after a StringBuffer has been constructed. This method determines whether a given string begins with a specified string or not.