Skip to content
Sharp

Collections · interview question

Which Java collection would you choose if you need to maintain insertion order and allow duplicates?

Multiple choiceEasychapter-4-curatedpremiumcollectionschoosing-the-right-collection
Choose one answer
Answer and explanation

Correct answer

C. ArrayList

Why

ArrayList maintains the order in which elements are inserted and allows duplicates. HashSet and TreeSet do not allow duplicates, and HashMap is not a collection of values but a map of keys to values.

Test yourself on Collections

A free test with instant, explained results. No account needed.

Start free test
All Collections questions →