Sail E0 Webinar
Question

Which statement is true for the class java.util.HashSet?


Options:
A .  The elements in the collection are ordered.
B .  The collection is guaranteed to be immutable.
C .  The elements in the collection are guaranteed to be unique.
D .  The elements in the collection are accessed using a unique key.
Answer: Option C

Option C is correct. HashSet implements the Set interface and the Set interface specifies 

collection that contains no duplicate elements.

Option A is wrong. HashSet makes no guarantees as to the iteration order of the set; in 

particular, it does not guarantee that the order will remain constant over time.

Option B is wrong. The set can be modified.

Option D is wrong. This is a Set and not a Map.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers