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. JButton class can associate with the icon or string with the button.

  2. JApplet class supports various panes.

  3. JCheckBox is a concrete implementation of AbstractButton.

  4. All of the above

  5. Only (1) and (2)

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

Yes, all the above are true statements.

Multiple choice
  1. TreeMap maintains the ascending order of the elements.

  2. TreeMap does not allow null keys.

  3. HashMap allows null key.

  4. There is no order of elements in the HashMap class.

  5. All of the above

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

All the statements are true.

Multiple choice
  1. Garbage collection can be forced explicitly.

  2. Garbage collection is done by JVM.

  3. User can request JVM for Garbage collection explicitly calling gc() method.

  4. Both 1 and 2 are true.

  5. Both 2 and 3 are true.

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

Option 2 and 3 both are true. Hence this option is the correct answer.

Multiple choice
  1. StringBuilder class is faster than StringBuffer class.

  2. StringBuilder is thread safe.

  3. StringBuffer str=new StringBuffer("hello"); //creates an immutable string object "str" which contains "hello"

  4. StringBuilder is synchronized.

  5. None of the above statements is true

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

 StringBuilder is not synchronized , where as StringBuffer is synchronized. Hence StringBuilder is faster than String Buffer.