Skip to content
Sharp

Core Java · interview question

When iterating over a LinkedHashMap, in what order are the entries returned?

Multiple choiceMediumchapter-4-curatedpremiumcore-javacode-reading-with-collections
Choose one answer
Answer and explanation

Correct answer

C. Order of insertion

Why

LinkedHashMap maintains a doubly-linked list of its entries to preserve the order of insertion, thus iterating over it returns elements in this order.

Test yourself on Core Java

A free test with instant, explained results. No account needed.

Start free test
All Core Java questions →