Skip to content
Sharp

Collections · interview question

Which collection does not allow duplicate elements?

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

Correct answer

B. HashSet

Why

HashSet does not allow duplicate elements, ensuring that all elements in the collection are unique. Other listed collections do allow duplicates.

Test yourself on Collections

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

Start free test
All Collections questions →