Java — Which collection class allows key-value associations and provides synchronization?

Difficulty: Easy

Correct Answer: java.util.Hashtable

Explanation:


Introduction / Context:
This checks knowledge of synchronized collections and legacy classes.



Concept / Approach:

  • Hashtable is synchronized, meaning its methods are thread-safe.
  • It stores key-value pairs like HashMap but synchronizes all methods.
  • TreeMap → ordered keys, but not synchronized.
  • SortedMap → interface, not a class.
  • TreeSet → stores unique values, not key-value pairs.


Final Answer:
java.util.Hashtable

More Questions from Objects and Collections

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion