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. An applet can contain main method.

  2. The code of the applet can be downloaded in a user's browser if the html page contain that applet.

  3. The Graphics class is used to display the output of the applet.

  4. An applet can be used to fetch an image.

  5. None of the above

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

No, applet does not allow main method.

Multiple choice
  1. By using serialization process, the state of the variable can be represented as a sequence of bytes.

  2. Serialization is a platform independent process.

  3. ObjectInputStream class is used to serialize or deserialize the object.

  4. All of the above are true

  5. Only (1) and (3) are true

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

Yes, all the above three statements determines the properties of the serialization process.

Multiple choice
  1. StringBuffer is a mutable class.

  2. StringBuilder is faster than StringBuffer.

  3. StringBuilder is a mutable class.

  4. All of the above are true

  5. None of the above

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

Yes, all of the above three are true.

Multiple choice
  1. We can not force garbage collection mechanism in java.

  2. JVM uses finalize() method before destroy the unused objects.

  3. JVM uses system.gc() method to collect the unused memory objects.

  4. All the above are true

  5. Option (1) and (2) only

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

Yes,  all of the above three a statements determines the exact explanation of the garbage collection process in java.

Multiple choice
  1. PrintWriter class object defined in System class

  2. Bufferwriter class defined in System class

  3. System class object

  4. PrintStream class defined in System class

  5. BufferReader class object

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

It is an object PrintStream class defined in System class. 'out' is declared as public, static and final.

Multiple choice
  1. Catch statement can rethrow an exception in Java.

  2. Empty catch block is accepted by Java.

  3. Main is a daemon thread.

  4. Garbage collector is a daemon thread.

  5. Garbage collector can also run forcibly.

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

Main is not a daemon thread, also any thread stem from main will be non daemon because daemon is derived from parent Thread class.

Multiple choice
  1. Return statement in catch block.

  2. System.exit() present in catch block.

  3. Exception occurred in finally block.

  4. The death of thread occurs before completion of execution.

  5. Break; statement in catch block.

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

Once execution enters the try block, the code in that finally block will definitely be executed.