Collections
- Is hashmap an ordered collection.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Hashmap outputs in the order of hashcode of the keys. So it is unordered but will always have same result for same set of keys.
- While finding the correct location for saving key value pair, how many times the key is hashed?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
The key is hashed twice; first by hashCode() of Object class and then by internal hashing method of HashMap class.
- What happens if we put a key object in a HashMap which exists?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
HashMap always contains unique keys. If same key is inserted again, the new object replaces the previous object.
- What is the premise of equality for IdentityHashMap?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
IdentityHashMap is rarely used as it violates the basic contract of implementing equals() and hashcode() method.
- Which of the below does not implement Map interface?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Vector implements AbstractList which internally implements Collection. Others come from implementing the Map interface.