Java MCQ: What is a LinkedHashMap in Java?
a) A map that maintains the insertion order of its elements
b) A map that sorts keys in natural order
c) A map that does not allow null values
d) A map that allows duplicate keys
Answer:
a) A map that maintains the insertion order of its elements
Explanation:
A LinkedHashMap
in Java is a map that maintains the insertion order of its elements, meaning it preserves the order in which keys were inserted into the map. It allows one null key and multiple null values.
Understanding LinkedHashMap
is important for managing collections where the order of elements is significant.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html