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. CharWriter

  2. StringWriter

  3. BufferedWriter

  4. Both 1 and 2

  5. Both 1 and 3

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

This is the correct answer. There is no Subclass named CharWriter. The correct name is CharArrayWriter, which is used for writing to a char array. So this is the correct answer according to the question.

Multiple choice
  1. StringReader

  2. PipeReader

  3. InputReader

  4. Both 1 and 2

  5. Both 1 and 3

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

There is no subclass of Reader class named InputReader. The correct name is InputStreamReader used for reading a character stream. So this is the correct answer according to the question.

Multiple choice
  1. Element() method retrieves and removes the head of the queue and returns Null if the queue is empty.

  2. Element() method retrieves, but doesn’t remove the head of the queue and returns Null if the queue is empty.

  3. Element() method retrieves and removes the head of the queue and throws exception if the queue is empty.

  4. Element() method retrieves, but doesn’t remove the head of the queue and throws exception if the queue is empty.

  5. Element() method removes the head of the queue and throws exception if the queue is empty.

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

This is the correct answer.

Multiple choice
  1. Poll() method retrieves and removes the head of the queue or returns Null if the queue is empty.

  2. Remove() method retrieves and removes the head of the queue or returns Null if the queue is empty.

  3. Poll() method retrieves and removes the head of the queue or throws an exception if the queue is empty.

  4. Remove() method retrieves and removes the head of the queue, but doesn’t return anything if the queue is empty.

  5. Poll() method retrieves the head of the queue or returns Null if the queue is empty.

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

This is the correct choice.

Multiple choice
  1. Peek() method retrieves and removes the head of the queue and returns Null if the queue is empty.

  2. Peek() method retrieves and removes the head of the queue and returns nothing if the queue is empty.

  3. Peek() method retrieves, but doesn’t remove the head of the queue and returns Null if the queue is empty.

  4. Peek() method retrieves and removes the head of the queue and throws an exception if the queue is empty.

  5. Peek() method retrieves, but doesn’t remove the head of the queue and throws an exception if the queue is empty.

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

This is the correct answer.