Which of the following classes will not allow unsynchronized read operations by multiple threads?

  1. Vector

  2. TreeMap

  3. TreeSet

  4. HashMap

  5. HashSet


Correct Option: A
Explanation:

To answer this question, the user needs to have knowledge of Java's synchronized collections and multithreading.

Option A: Vector is a synchronized collection class, which means that multiple threads can read and write from it but only one thread can access it at a time. Therefore, unsynchronized read operations are not allowed by multiple threads in Vector.

Option B: TreeMap is not a synchronized collection class, and therefore, it does not provide thread-safety. Multiple threads can read and write to it at the same time, which means that unsynchronized read operations are allowed by multiple threads in TreeMap.

Option C: TreeSet is not a synchronized collection class, and therefore, it does not provide thread-safety. Multiple threads can read and write to it at the same time, which means that unsynchronized read operations are allowed by multiple threads in TreeSet.

Option D: HashMap is not a synchronized collection class, and therefore, it does not provide thread-safety. Multiple threads can read and write to it at the same time, which means that unsynchronized read operations are allowed by multiple threads in HashMap.

Option E: HashSet is not a synchronized collection class, and therefore, it does not provide thread-safety. Multiple threads can read and write to it at the same time, which means that unsynchronized read operations are allowed by multiple threads in HashSet.

Therefore, the answer is: A. Vector

Find more quizzes: