Self-Review Exercises 2
Self-Review Exercises
16.1 Fill in the blanks in each of the following statements:
a) A(n) is used to iterate through a collection and can remove elements from the
collection during the iteration.
b) An element in a List can be accessed by using the element’s .
c) Assuming that myArray contains references to Double objects, occurs when
d) Class provides the capabilities of array-like data structures that can resize
e) You can use a(n) to create a collection that offers only read-only access to oth-
f) Assuming that myArray contains references to Double objects, occurs when
the statement “double number = myArray[0];” executes.
g) Collections algorithm determines if two collections have elements in com–
mon.
16.2 Determine whether each statement is true or false. If false, explain why.
a) Values of primitive types may be stored directly in a collection.
b) A Set can contain duplicate values.
c) A Map can contain duplicate keys.
d) A LinkedList can contain duplicate values.
e) Collections is an interface.
f) Iterators can remove elements.
g) With hashing, as the load factor increases, the chance of collisions decreases.
h) A PriorityQueue permits null elements.
Exercises
NOTE: Solutions to the programming exercises are located in the ch16solutions folder.
Each exercise has its own folder named ex16_## where ## is a two-digit number represent-
ing the exercise number. For example, exercise 16.9’s solution is located in the folder
ex16_09.
© 2018 Pearson Education, Inc., 330 Hudson Street, NY NY 10013. All rights reserved.