Which interface does TreeMap class implement ?
-
Set
-
SortedSet
-
List
-
Tree
-
SortedMap
TreeMap implements the SortedMap interface (and AbstractMap). It provides a red-black tree implementation of a Map that maintains its keys in sorted order. SortedMap is the interface that defines the contract for maps with sorted keys. Options A (Set), B (SortedSet), C (List), and D (Tree) are incorrect interfaces for TreeMap.
To answer this question, we need to understand the TreeMap class in Java.
The TreeMap class in Java implements the SortedMap interface.
The SortedMap interface is a sub-interface of the Map interface and extends it. It represents a map that is sorted according to the natural ordering of its keys or a custom Comparator.
Therefore, the correct answer is E) SortedMap.