Skip to content
Sharp

Collections · interview question

Which collection allows you to store key-value pairs where quick lookup of product details by ID is crucial?

Multiple choiceMediumchapter-4-curatedpremiumcollectionscollection-performance-basics
Choose one answer
Answer and explanation

Correct answer

C. HashMap

Why

HashMap offers O(1) average time complexity for get and put operations, making it ideal for scenarios where quick lookup of product details by ID is essential.

Test yourself on Collections

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

Start free test
All Collections questions →