Skip to content
Sharp

Collections · interview question

A shopping cart must preserve item order and allow the same product to appear more than once. Which collection contract fits best?

Multiple choiceEasychapter-4-curatedpremiumcollectionschoosing-the-right-collection
Choose one answer
Answer and explanation

Correct answer

C. A List, usually implemented with ArrayList

Why

A cart line collection usually needs ordering plus duplicates. That points to List semantics first, and ArrayList is the common default implementation when indexed reads and simple appends dominate.

Test yourself on Collections

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

Start free test
All Collections questions →