Quiz 9 (ch 13)
In the SeparateIterator class, how does the method next behave when iteration has ended? It throws an exception. It returns null. It returns the last element in the list It returns false.
It throws an exception.
The constructor in the SeparateIterator class initializes the iterator so it begins at the first entry in the list connects the iterator to the list in question both a & b none of the above
both a & b
The _____ deletes the most recent entry returned from the next method from the list. remove clear deleteNext delete
remove
A class that is public and separate from the class that implements the ADT in question is called a(n) outer class iterator public iterator inner class iterator separate class iterator
separate class iterator
In the SeparateIterator class, when the data field wasNextCalled is true it means that the list is empty that iteration has stopped that a call to remove is safe all of the above
that a call to remove is safe
If iteration has ended, the next method throws an exception returns null returns 0 returns false
throws an exception
A separate class iterator is usually preferable to an inner class iterator. True False
False
If you use a separate class iterator, you cannot have multiple and distinct iterations of a list exist simultaneously. True False
False
The definition of the class SeparateIterator is dependent on which implementation of a list you choose. True False
False
You invoke the methods of the inner class iterator and the separate class iterator differently. True False
False
A class that defines an inner class iterator should implement the interface Iterable. True False
True
A separate class iterator can take longer to execute than an inner class iterator. True False
True
An inner class iterator typically executes faster than a separate class iterator because it accesses the list ADT's data directly. True False
True
An iterator does not typically allow the removal of items during a traversal. True False
True
An iterator that is implemented as an inner class of a list ADT has direct access to the ADT's data fields. True False
True
The class SeparateIterator cannot access the private data fields of the class that implements the list. True False
True
Which method does the interface Iterator specify? hasNext next remove all of the above
all of the above
After a call to remove, the nextPosition data field should be incremented left unaltered set to 0 decremented
decremented
A class that is a private inner class of the class that implements the ADT in question is called a(n) inner class iterator outer class iterator private iterator separate class iterator
inner class iterator
A(n) ____ is an object that enables you to traverse a list. list counter walker traversal object iterator
iterator