Question: 1. Which methods are required for an iterator (i.e. which ones you must implement if your class implements Iterator interface) ? Select all that apply.
1. Which methods are required for an iterator (i.e. which ones you must implement if your class implements Iterator interface) ?
Select all that apply.
a. next() b. previous() c. add() d. remove() e. hasNext() f. hasPrevious()
2. Given the iterator discussed in class, where is the current position of the iterator iter at the end of the given code sequence? LL l = new LL([A, B, C, D]) iter = l.iterator() iter.next() iter.next()
select one:
a. positioned at A b. positioned at B c. positioned at C d. positioned before A e. positioned between A and B f. positioned between B and C
3. Given the iterator operations as discussed in class, what will be the contents of list l at the end of the given code sequence? LL l = new LL([A, B, C, D]) iter = l.iterator() iter.next() iter.add(X) iter.next() iter.remove()
select one:
a. [ A B C D ] b. [ A X B D ] c. [ A X C D ] d. [ X A C D ] e. [ X A B D ] f. error
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
