4Chapter 7 Arrays and ArrayLists
Exercises
NOTE: Solutions to the programming exercises are located in the ch07solutions folder.
Each exercise has its own folder named ex07_## where ## is a two-digit number represent-
ing the exercise number. For example, exercise 7.10’s solution is located in the folder ex-
07_10.
7.6 Fill in the blanks in each of the following statements:
a) One-dimensional array p contains four elements. The names of those elements are
, , and .
b) Naming an array, stating its type and specifying the number of dimensions in the array
is called the array.
c) In a two-dimensional array, the first index identifies the of an element and the
second index identifies the of an element.
d) An m-by-n array contains rows, columns and elements.
e) The name of the element in row 3 and column 5 of array d is .
7.7 Determine whether each of the following is true or false. If false, explain why.
a) To refer to a particular location or element within an array, we specify the name of the
array and the value of the particular element.
b) An array declaration reserves space for the array.
c) To indicate that 100 locations should be reserved for integer array p, you write the dec-
laration
p[100];
d) An application that initializes the elements of a 15-element array to zero must contain
at least one for statement.
e) An application that totals the elements of a two-dimensional array must contain nested
for statements.
7.8 Write Java statements to accomplish each of the following tasks:
a) Display the value of element 6 of array f.
b) Initialize each of the five elements of one-dimensional integer array g to 8.
c) Total the 100 elements of floating-point array c.
d) Copy 11-element array a into the first portion of array b, which contains 34 elements.