Skip to content
Sharp

Collections · interview question

Given an e-commerce application that requires frequent updates and lookups of product prices, which collection would you choose and why?

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

Correct answer

D. HashMap for key-value association

Why

HashMap is ideal for storing key-value pairs like product IDs and prices, offering average constant-time complexity for insertions and lookups.

Test yourself on Collections

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

Start free test
All Collections questions →