Question 1
Which method of HashMap is used to check if a key exists?
containsKey()
hasKey()
keyExists()
isKey()
Question 2
Which of the following is true about LinkedHashMap in Java?
It does not maintain the insertion order
It allows only unique values
It maintains the insertion order
It is slower than HashMap in terms of performance
Question 3
What is the time complexity of the get() method in a HashMap?
O(log n)
O(n)
O(1)
O(n^2)
Question 4
What does the TreeMap store in Java?
Elements in random order
Key-value pairs in ascending order of keys
Only the keys, sorted
Only the values, sorted
Question 5
Which of the following does NOT allow null keys in Java?
HashMap
TreeMap
LinkedHashMap
None of the above
Question 6
Which of the following is true about HashMap in Java?
It does not maintain any order of keys
It does not allow duplicate keys
It allows null values and null keys
All of the above
Question 7
Which Map implementation maintains the insertion order of keys?
HashMap
TreeMap
LinkedHashMap
EnumMap
Question 8
What happens when you insert a new entry with a key that already exists in a HashMap?
The map throws an exception
The existing value is replaced
Both values are stored
The new value is ignored
Question 9
Which Map implementation stores keys in sorted (natural) order?
HashMap
TreeMap
LinkedHashMap
IdentityHashMap
Question 10
Which of the following allows one null key and multiple null values?
HashMap
TreeMap
LinkedHashMap
Both a and c
There are 10 questions to complete.