Skip to content
Sharp

Collections · interview question

You need a collection for product categories that allows null elements and quick random access. What would you use?

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

Correct answer

D. ArrayList

Why

ArrayList allows null elements and provides quick random access to elements via indexes, making it suitable for storing product categories in this scenario.

Test yourself on Collections

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

Start free test
All Collections questions →