Java — Which interface does java.util.Hashtable implement?

Difficulty: Easy

Correct Answer: java.util.Map

Explanation:


Introduction / Context:
The java.util.Hashtable class is one of the legacy collection classes in Java. Understanding which interfaces it implements is key to using it correctly in modern Java programming.



Given Data / Assumptions:

  • Hashtable is a dictionary-like data structure storing key-value pairs.
  • Located in java.util package.
  • Modern usage often prefers HashMap, but Hashtable remains important historically.


Concept / Approach:
Hashtable implements the Map interface, which defines methods for mapping keys to values without duplicates.



Step-by-Step Reasoning:

Hashtable extends Dictionary (legacy) but implements Map.Map ensures unique keys, allows value lookup, insertion, and removal.List and Collection are not correct because they do not define key-value mapping.


Why Other Options Are Wrong:

  • List → ordered sequence, not key-value mapping.
  • HashTable (spelled incorrectly) is not an interface.
  • Collection is more general, but Hashtable implements Map, not Collection directly.


Final Answer:
java.util.Map

Discussion & Comments

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