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. There should be a catch block to execute finally clause.

  2. Finally block is executed only when there is an exception in a program.

  3. JVM always executes finally block before terminating the program.

  4. Finally block can be put before catch block.

  5. Finally block can handle the exception in the code.

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

JVM executes finally block just before terminating the program to close the connection and resources.

Multiple choice
  1. start() method starts a thread by calling its run method.

  2. run() is an entry point for the thread.

  3. sleep() method temporarily suspends a currently executing thread.

  4. isAlive() method determines if a thread is still running.

  5. join() method waits for a thread to terminate.

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

This is a false statement because sleep() method causes the currently executing thread to sleep for the specified number of milliseconds.

Multiple choice
  1. Hashtable is synchronised.

  2. A list can contain duplicate elements but a set cannot.

  3. HashMap is used for non-threaded applications.

  4. ArrayList dynamically increases or decreases in size.

  5. ArrayList is synchronised.

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

ArrayList is not synchronised.

Multiple choice
  1. IllegalArgumentException

  2. NullPointerException

  3. IOException

  4. IndexOutOfBoundException

  5. ArithmeticException

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

IOException is not a subclass of RuntimeException class, this class is a Subclass of Exception class.This exception is thrown when invalid input/output are given.So this is the correct answer as this is not a subclass of RuntimeException class.