Skip to content
Sharp

Collections · interview question

Which of the following is a primary characteristic of a HashSet in Java?

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

Correct answer

A. It ensures unique elements.

Why

A HashSet in Java does not allow duplicate elements and is not synchronized by default. It also does not maintain any order of elements.

Test yourself on Collections

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

Start free test
All Collections questions →