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. 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. This method is called by the browser to unload the applet.

  2. This method is called by the browser, when applet is first loaded.

  3. This method is called by the browser, when an applet should start or resume its execution.

  4. This method is called by the browser to suspend execution of the applet and if it will be restarted again when browser returns that page by start() method.

  5. This method returns the URL associated with that applet.

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

stop() method is called for that.

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. This class gives buffered input character stream.

  2. This is an input stream that reads from a character array.

  3. This is an input stream that translates bytes to characters.

  4. This is an input stream that counts lines.

  5. This is an output stream that translates characters to bytes.

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

Its a true statement about InputStreamReader class.

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.