Multiple choice technology programming languages

8) How will you remove duplicate element from a List?

  1. Add the List elements to Set

  2. List doesnt allow that

  3. using remove()

  4. none of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A Set in Java automatically removes duplicates because it only stores unique elements. By adding all elements from a List to a Set (like HashSet), duplicates are automatically eliminated. You can then convert back to a List if needed.