Skip to content
Sharp

Collections · interview question

What property of the HashSet collection makes it suitable for storing unique items in a catalog?

Multiple choiceEasychapter-4-curatedpremiumcollectionsset-interface-and-hashset
Choose one answer
Answer and explanation

Correct answer

C. It enforces uniqueness of elements.

Why

The HashSet collection enforces uniqueness of elements, meaning it does not allow duplicate entries. This makes it suitable for storing unique items in a catalog.

Test yourself on Collections

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

Start free test
All Collections questions →