Skip to content
Sharp

Core Java · interview question

Which Java collection would you choose if you need to maintain the order of insertion without allowing duplicate values?

Multiple choiceEasychapter-4-curatedpremiumcore-javacode-reading-with-collections
Choose one answer
Answer and explanation

Correct answer

C. LinkedHashSet

Why

LinkedHashSet maintains the order of insertion and does not allow duplicate values, making it the best choice for this scenario.

Test yourself on Core Java

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

Start free test
All Core Java questions →