Skip to content
Sharp

Collections · interview question

In which scenario would a HashMap be more appropriate than a List?

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

Correct answer

B. When you need fast lookups by key.

Why

A HashMap is more appropriate when you need fast lookups by key due to its average constant-time complexity for get() and put() operations, whereas a List requires linear time complexity for lookups.

Test yourself on Collections

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

Start free test
All Collections questions →