Multiple choice technology programming languages

Which is the data structure used to store sorted map elements ?

  1. HashSet

  2. Hashmap

  3. Map

  4. TreeMap

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

TreeMap stores its elements in a red-black tree, which automatically keeps the keys sorted according to their natural ordering or a custom comparator. HashMap and HashSet use hashing and do not guarantee order, while Map is an interface that cannot be instantiated directly.