Skip to content
Sharp

Collections · interview question

If you need a sorted collection of unique product names with frequent reads, which collection is optimal?

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

Correct answer

D. TreeSet

Why

TreeSet is a collection that stores elements in a sorted order and ensures uniqueness. It provides efficient operations for reads while maintaining order.

Test yourself on Collections

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

Start free test
All Collections questions →