Skip to content
Sharp

Collections · interview question

The code repeatedly needs Product by SKU. Which model communicates that lookup need most clearly?

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

Correct answer

C. Map<String, Product>

Why

A map is the clearest way to say one key leads directly to one value. If SKU lookup dominates, a Map<String, Product> expresses that intent better than repeatedly scanning a list.

Test yourself on Collections

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

Start free test
All Collections questions →