DSAJ5 Test-Bank-Chapter 13.docx - Chapter 13 Iterators for the ADT List True\/False(11 1 A separate class iterator is usually preferable to an inner

DSAJ5 Test-Bank-Chapter 13.docx - Chapter 13 Iterators for...

This preview shows page 1 - 3 out of 7 pages.

Chapter 13 - Iterators for the ADT ListTrue/False (11)1.A separate class iterator is usually preferable to an inner class iterator.Answer: false2.You invoke the methods of the inner class iterator and the separate class iterator differently.Answer: false3.The definition of the class SeparateIterator is dependent on which implementation of a list you choose.Answer: false4.The class SeparateIterator cannot access the private data fields of the class that implements the list.Answer: true5.A separate class iterator can take longer to execute than an inner class iterator.Answer: true6.If you use a separate class iterator, you cannot have multiple and distinct iterations of a list exist simultaneously.Answer: false7.When a list iterator object is distinct from the list ADT you can have multiple iterations in progress at the same time.Answer: true8.An iterator that is implemented as an inner class of a list ADT has direct access to the ADT’s data fields.Answer: true9.A class that defines an inner class iterator should implement the interface Iterable.Answer: true10.An iterator does not typically allow the removal of items during a traversal.
Background image
Answer: true 11.An inner class iterator typically executes faster than a separate class iterator because it accesses the list ADT’s data directly.3.Why is it better to implement the iterator as a class, whether separate or inner, than simply adding the iterator functionality as additional ADT operations? Short Answer (5)1.Using the LinkedListWithInterator class, create an iterator named printIterator. The objects in thelist object are type String. The list object is called reports.2.Using the LinkedListWithInterator class, create an iterator named rosterIterator. The objects in the list object are type Student. The list object is called collegeClass.Iterator<Student> rosterIterator = collegeClass.getIterator();
Background image
Image of page 3

You've reached the end of your free preview.

Want to read all 7 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture