Skip to content
Sharp

Collections · interview question

You need a collection for an in-memory product catalog where order matters and items must be unique. Which collection is the best choice?

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

Correct answer

A. LinkedHashSet

Why

LinkedHashSet maintains insertion order and ensures that all elements are unique, which makes it suitable for an in-memory product catalog where both these properties are required.

Test yourself on Collections

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

Start free test
All Collections questions →