Java MCQ: What does the Set interface represent?
a) A collection that does not allow duplicates
b) A collection that allows null values
c) A collection that maintains order
d) A collection that maps keys to values
Answer:
a) A collection that does not allow duplicates
Explanation:
The Set
interface in Java represents a collection that does not allow duplicate elements. It models the mathematical set abstraction and is implemented by classes such as HashSet
, LinkedHashSet
, and TreeSet
.
Understanding sets is essential for managing unique collections of elements in Java applications.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html