← Quiz: Java Enums: all 10 questions
Quiz: Java Enums · Question 10 of 10
Which collection is designed for enum keys and keeps them in declaration order?
Which collection is designed for enum keys and keeps them in declaration order?
- A.HashMap
- B.TreeMap with a comparator
- C.LinkedList
- D.EnumMap
Answer & explanation
Correct answer: EnumMap
EnumMap uses each constant's ordinal internally, so it is compact and ordered.
Can you get the rest right without peeking?
Take the timed Quiz: Java Enums quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →