Skip to content
Sharp

Collections · interview question

How would you explain the key difference between a Set and a List in a Java interview?

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

Correct answer

D. Set does not allow duplicates, List does

Why

The key difference is that a Set does not allow duplicate elements, while a List does. Additionally, Lists maintain the order of elements, whereas Sets typically do not, unless they're LinkedHashSet or TreeSet.

Test yourself on Collections

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

Start free test
All Collections questions →