Question 1
What is the main characteristic of the Set interface in Java?
Maintains insertion order
Does not allow duplicate elements
Allows duplicate elements
Stores elements in key-value pairs
Question 2
Which Set implementation maintains the insertion order of elements?
HashSet
TreeSet
LinkedHashSet
SortedSet
Question 3
Which Set implementation sorts elements in natural order?
HashSet
TreeSet
LinkedHashSet
EnumSet
Question 4
Which of the following is true about TreeSet in Java?
It allows duplicate elements
It stores elements in random order
It stores elements in sorted order
It is an implementation of List
Question 5
What is the default initial capacity of a HashSet in Java?
10
20
5
16
Question 6
What is the primary difference between HashSet and TreeSet?
HashSet stores elements in a sorted order, while TreeSet does not
HashSet allows duplicates, while TreeSet does not
HashSet is faster than TreeSet for adding elements
HashSet stores elements in an unordered manner, while TreeSet stores elements in sorted order
Question 7
Which of the following collections allows for null elements in Java?
TreeSet
LinkedHashSet
HashSet
None of the above
There are 7 questions to complete.