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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started