Loading

Q1.

Which property makes TreeSet unique among Set implementations?

A. It maintains insertion order

B. It stores elements in sorted order

C. It allows duplicate values

D. It allows multiple nulls


Q2.

What is the underlying data structure of a TreeSet in Java?

A. HashMap

B. Hashtable

C. TreeMap (Red-Black Tree)

D. LinkedList


Q3.

How many null values can a TreeSet contain?

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

Q4.

 What will happen if we try to insert a heterogeneous object into a TreeSet without a custom Comparator?

A. It will accept it

B. It will replace existing values

C. It will throw ClassCastException

D. It will sort automatically


Q5.

Which of the following interfaces does TreeSet implement?

A. Set, List, Map

B. Set, SortedSet, NavigableSet

C. Collection, List, SortedMap

D. Set, Queue, Deque