Java LinkedHashMap MCQ Questions and Answers
Q. What is the order of elements in a LinkedHashMap in Java?
A. Insertion orderB. Reverse insertion order
C. Alphabetical order
D. Reverse alphabetical order
Q. Which interface does LinkedHashMap implement in Java?
A. MapB. Set
C. List
D. Queue
Q. How does LinkedHashMap maintain insertion order in Java?
A. By using a doubly linked listB. By using a singly linked list
C. By using a red-black tree
D. By using a hash table
Q. What is the time complexity of get() operation in LinkedHashMap in Java?
A. O(1)B. O(log n)
C. O(n)
D. O(n log n)
Q. What is the time complexity of put() operation in LinkedHashMap in Java?
A. O(1)B. O(log n)
C. O(n)
D. O(n log n)
Q. What is the time complexity of removing an element from a LinkedHashMap in Java?
A. O(1)B. O(log n)
C. O(n)
D. O(n log n)
Q. How can you iterate over the keys in a LinkedHashMap in Java?
A. Using a for-each loopB. Using an iterator
C. Using a while loop
D. All of the above
Q. What is the output order of keys() iterator in LinkedHashMap in Java?
A. Insertion orderB. Reverse insertion order
C. Alphabetical order
D. Reverse alphabetical order
Q. How can you create a LinkedHashMap with a specific initial capacity in Java?
A. LinkedHashMap(int initialCapacity)B. LinkedHashMap(Map m)
C. LinkedHashMap(int initialCapacity, float loadFactor)
D. All of the above
Q. What is the load factor of a LinkedHashMap by default in Java?
A. 0.5B. 0.75
C. 1.0
D. 0.25
Q. What is the output order of values() iterator in LinkedHashMap in Java?
A. Insertion orderB. Reverse insertion order
C. Alphabetical order of keys
D. Reverse alphabetical order of keys