Skip to content
Sharp

Collections · interview question

Which Java collection is best suited for storing unique product IDs with fast lookup?

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

Correct answer

C. HashSet

Why

HashSet is designed to store unique elements and provides average constant-time performance for basic operations like add, remove, and contains.

Test yourself on Collections

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

Start free test
All Collections questions →