Which of the following statements are true?
-
At the root of the collection hierarchy is a class called Collection
-
The collection interface contains a method called enumerator
-
The interator method returns an instance of the Vector class
-
The Set interface is designed for unique elements
Set interface specifically prohibits duplicate elements. Collection is an interface, not a class. There's no 'enumerator' method in Collection, and iterator() returns Iterator, not Vector.
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) At the root of the collection hierarchy is a class called Collection - This option is incorrect because the root of the collection hierarchy is an interface called Collection, not a class.
Option B) The collection interface contains a method called enumerator - This option is incorrect because the Collection interface does not contain a method called enumerator. However, it does contain a method called iterator, which returns an Iterator object.
Option C) The iterator method returns an instance of the Vector class - This option is incorrect because the iterator method does not return an instance of the Vector class. The iterator method returns an Iterator object, which is used to iterate over the elements in a collection.
Option D) The Set interface is designed for unique elements - This option is correct because the Set interface is designed to store unique elements. It does not allow duplicate elements in a Set implementation.
The correct answer is D. The Set interface is designed for unique elements because it does not allow duplicate elements in a Set implementation.