Skip to content
Sharp

Collections · interview question

Which collection should you choose if you want to ensure the order of product IDs remains consistent with their insertion?

Multiple choiceEasychapter-4-curatedpremiumcollectionscollection-performance-basics
Choose one answer
Answer and explanation

Correct answer

B. LinkedHashSet

Why

LinkedHashSet maintains insertion order while ensuring uniqueness of elements, making it suitable for cases where the order of elements is important.

Test yourself on Collections

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

Start free test
All Collections questions →