Collections
1.Which Java collection allows duplicate keys?
-
A. HashMap
-
B. TreeMap
-
C. LinkedHashMap
-
D. None of the above
None of the above
None of the above
2.What is the default initial capacity of an ArrayList?
-
A. 8
-
B. 10
-
C. 12
-
D. 16
10
10
3.What is the time complexity of inserting an element in a HashSet (on average)?
-
A. O(1)
-
B. O(log n)
-
C. O(n)
-
D. O(n log n)
O(1)
O(1)
4.What will happen if you try to insert a null key into a TreeMap?
-
A. It will store the null key
-
B. It will throw a NullPointerException
-
C. It will replace the existing elements
-
D. It will be ignored
It will throw a NullPointerException
It will throw a NullPointerException
5.Which Java collection provides a fail-fast iterator?
-
A. CopyOnWriteArrayList
-
B. ConcurrentHashMap
-
C. HashMap
-
D. TreeSet
HashMap
HashMap