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

  2. Double

  3. Long

  4. Character

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

This answer is correct. Long, Byte, Short, Integer classes do have the decode method which will return the respective Class object like Long, Byte, Short, Integer based on the call from the respective classes. Also,  the object that is returned contains the value specified by the string.

Multiple choice
  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true

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

This answer is correct. HashMap allows null in the key value pairs. It can have null in the key as well as values. Hashtable does not allow null in the key value pairs. It will not have any null in the key or value pairs.

Multiple choice
  1. i. and iii. are true.

  2. i. and iv. are true.

  3. ii. and iii. are true

  4. ii. and iv. are true.

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

This answer is correct. HashMap is not thread-safe or synchronized. In other words, HashMap is non-synchronized. So, the key value pair is not thread-safe. Hashtable is thread-safe or synchronized.The key value pair will not be affected by different threads.

Multiple choice
  1. i. and iii. are true.

  2. i. and iv. are true

  3. ii. and iii. are true.

  4. ii. and iv. are true.

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

This answer is correct. Iterator is used to obtain the elements from the collection in forward direction only. Also, it has the capability to remove the elements from the collection. List Iterator is used to obtain the elements from the collection in forward direction only. Also, it has the capability to modify the elements in the collection.

Multiple choice
  1. Insert(int index, string str)

  2. Reverse()

  3. Format(string str)

  4. Delete(int startIndex, int endIndex)

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

This answer is correct because format(string str) does not exist in String Buffer class.

Multiple choice
  1. i. is true

  2. ii. is true

  3. iii. is true

  4. iv. is true

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

This answer is correct because Serializable interface is a marker interface and does not have any methods. This interface when implemented, tells the object serializable tools whether the class is serializable or not.

Multiple choice
  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true.

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

The answer is correct.The Reader/Writer class is used when any manipulation needs to be done on characters whereas InputStream/OutputStream class is used when any manipulation needs to be done on bytes.