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. class MyClass extends Runnable { public void run() { } }

  2. class MyClass implements Thread { public void run() { } }

  3. class Thread MyClass { public void run() { } }

  4. class MyClass extends Thread { public void run() { } }

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

The correct structure is: class MyClass extends Thread {       public void run()       {       } }

Multiple choice
  1. IllegalMonitorException

  2. IllegalStateException

  3. IllegalMonitorStateException

  4. IllegalMonitorOwnStateException

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

All these methods must be called only when they own the monitor of that object, otherwise they throw IllegalMonitorStateException exception. These methods are used for proper coordination among the threads.