Question
Which statement about TreeSet and NavigableSet is the strongest interview answer?
- TreeSet and NavigableSet is mostly a naming style choice and has little effect on runtime or design.
- TreeSet stores unique elements in sorted order and supports navigational lookups around a target value.
- TreeSet and NavigableSet exists mainly to reduce the number of Java files in a project.
- TreeSet and NavigableSet matters only for frontend frameworks, not for core Java applications.
Hint
Start with the core rule behind TreeSet and NavigableSet.
Answer and rationale
Correct answer: B. TreeSet stores unique elements in sorted order and supports navigational lookups around a target value.
TreeSet stores unique elements in sorted order and supports navigational lookups around a target value. This is the base concept interviewers commonly test first.
Track: Java