Self-Assessment Exercises
Chapter 13:
Processing Data in Collections
1.
Which of the following is a valid Java wrapper class?
a.
Char
b.
Double
c.
Int
d.
All of the above
2.
Java iterators ________.
a.
are objects that encapsulate the ability to visit each element in a collection
b.
implement the
hasNext()
,
next()
, and
remove()
methods
c.
implement the
Iterator
interface
d.
All of the above
3.
A programming operation is said to be “expensive” when the operation ________.
a.
is difficult to debug
b.
requires a correction after the program ships to customers
c.
takes a (relatively) long time to execute
d.
All of the above
4.
Which of the following is NOT true of linked lists?
a.
Each element in a linked list is called a link.
b.
Linked lists can be singly linked or doubly linked.
c.
LinkedList
implements the
Collection
interface.
d.
ListIterator
adds new methods to
Iterator
including
previous()
and
hasPrevious()
.
5.
A set is a collection with no duplicate elements. Object
obj1
is considered a duplicate of object
obj2
when ________.
a.
they are actually the same object
b.
they have identical values in their corresponding fields
c.
obj1.equals(obj2)
returns true
d.
All of the above