Skip to content
Sharp

Collections · interview question

In Java, which collection should you use if you need fast lookup and do not care about the order of elements?

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

Correct answer

A. HashSet

Why

HashSet provides fast lookup due to its hash-based structure and does not maintain any order. HashMap is for key-value pairs, LinkedList maintains order, and TreeMap is sorted.

Test yourself on Collections

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

Start free test
All Collections questions →