You need to create a class that will store unique object elements. You do not need to sort these elements but they must be unique. What interface might be most suitable to meet this need?

  1. Set

  2. List

  3. Map

  4. Vector


Correct Option: A
Explanation:

To store unique object elements without sorting, the most suitable interface would be a Set.

A Set is a collection that contains no duplicate elements. It provides methods to add, remove, and check if an element is present. Additionally, it does not guarantee the order of the elements.

A List is an ordered collection that allows duplicates. A Map is a collection that maps key-value pairs, and a Vector is a synchronized version of the List interface. None of these interfaces guarantee uniqueness of elements without additional implementation.

Therefore, the option that best suits the given requirement is:

The Answer is: A - Set

Find more quizzes: