Skip to content
Sharp

Collections · interview question

When iterating over a HashMap using entrySet(), what type is each element?

Multiple choiceMediumchapter-4-curatedpremiumcollectionsmap-interface-and-hashmap
Choose one answer
Answer and explanation

Correct answer

A. Map.Entry<K, V>

Why

The entrySet() method returns a Set view of the mappings contained in the map, where each element is a Map.Entry<K, V> representing a key-value pair.

Test yourself on Collections

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

Start free test
All Collections questions →