🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.HashMap
  2. B.TreeMap with a comparator
  3. C.LinkedList
  4. 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 →