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. It returns the next token as a String.

  2. It returns the next token as an Object.

  3. It returns the number of tokens left to be parsed.

  4. It returns true if one or more tokens remain in the string.

  5. None of the above

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

This is task of nextElement() in StringTokenizer class.

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.