Collections Framework – Multiple Choice Questions (MCQs)
-
-
14. How do you iterate over the elements of a `Collection` using an `Iterator`?
-
15. What is the purpose of the `ListIterator` interface?
-
16. What are generics in the Java Collections Framework?
-
17. How do you declare an `ArrayList` that can only store `String` objects?
-
18. What happens if you try to add an object of a different type to a generic collection?
-
19. Which interface represents a collection that does not allow duplicate elements and provides methods for accessing elements in sorted order?
-
20. Which class implements the `SortedSet` interface?
-
21. Which interface represents a map that provides methods for accessing entries in sorted order of keys?
-
22. Which class implements the `SortedMap` interface?
-
23. What is the purpose of the `Comparable` interface?
-
24. What is the purpose of the `Comparator` interface?