Question
Which statement about TreeMap and NavigableMap is the strongest interview answer?
- TreeMap keeps keys sorted and supports navigation methods like ceiling, floor, higher, and lower.
- TreeMap and NavigableMap is mostly a naming style choice and has little effect on runtime or design.
- TreeMap and NavigableMap exists mainly to reduce the number of Java files in a project.
- TreeMap and NavigableMap matters only for frontend frameworks, not for core Java applications.
Hint
Start with the core rule behind TreeMap and NavigableMap.
Answer and rationale
Correct answer: A. TreeMap keeps keys sorted and supports navigation methods like ceiling, floor, higher, and lower.
TreeMap keeps keys sorted and supports navigation methods like ceiling, floor, higher, and lower. This is the base concept interviewers commonly test first.
Track: Java