Difficulty: Easy
Correct Answer: 1, 3, 4 and 5
Explanation:
Introduction / Context: Java provides Iterator for one-way traversal and ListIterator for bidirectional traversal and in-place modification of lists. This question checks which capabilities belong to which interface.
Given Data / Assumptions:
Iterator, inheritance relationships, and features of ListIterator.Concept / Approach: Iterator declares exactly three methods: hasNext(), next(), and remove(). ListIterator extends Iterator (not List) and adds backward traversal (hasPrevious(), previous()), modification methods (add(), set(), and remove() inherited), and positional queries (nextIndex(), previousIndex()).
Step-by-Step Solution:
1 is true: Iterator has exactly 3 methods.2 is false: ListIterator extends Iterator, not List.3 is true: ListIterator supports forward/backward traversal.4 is true: ListIterator can modify the list during iteration.5 is true: ListIterator can report its current index positions.Verification / Alternative check: The Javadoc for java.util.ListIterator lists these additional methods explicitly and shows it extends Iterator.
Why Other Options Are Wrong:
Common Pitfalls: Confusing List (a collection type) with ListIterator (an iterator over lists), and forgetting the backward traversal capability.
Final Answer: 1, 3, 4 and 5
Discussion & Comments