Loading

Q1.

Which of the following is a property of the Set interface in Java?

A. Allows duplicate elements

B. Maintains index-based access

C. Allows only unique elements

D. Does not allow iteration

Q2.

Which Set implementation maintains insertion order?

A. Hashset
B. TreeSet
C. LinkedHashSet
D. EnumSet

Q3.

What will happen if you insert a duplicate element into a HashSet?

A. It will throw an exception

B. It will add the duplicate element

C. It will ignore the duplicate element

D. It will remove the old element and add the new one

Q4.

Which Set implementation stores elements in sorted order?

A. HashSet
B. TreeSet
C. LinkedHashSet
D. All of the above

Q5.

How many null values can a Set store in Java?

A. None
B. One
C. Multiple
D. Depends on implementation