Skip to content
Sharp

Collections · interview question

Which method checks if a HashSet is empty?

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

Correct answer

D. IsEmpty()

Why

The isEmpty() method is used to check whether a HashSet contains no elements. It returns true if the set is empty.

Test yourself on Collections

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

Start free test
All Collections questions →