You are on page 1of 3

Name:

SKILLS WARM-UP

True or False. Write your answer in the space provided.

True 1. Arrays have a fixed number of elements.


False 2. Arrays are made up only of numbers.
False 3. A single array can hold components of many different data types.
False 4. The statement
int[] list = new int[15];
creates list to be an array of 14 components because array index starts at 0.

True 5. When an array object is instantiated, its components are initialized to their default
values.
False 6. The following statement creates alpha to be a two-dimensional array of 35
components.
int[][] alpha = new int[20][15];
False 7. In Java, the array index starts at 1.
False 8. Arrays can be initialized when they are created.
True 9. When an application contains an array and you want to use every element of the
array in some task, it is common to perform loops that vary the loop control variable
from 0 to one less than the size of the array.
True 10. Two-dimensional arrays generally contain data in table form.

SKILLS WORKOUT

Multiple Choice: Encircle the letter that corresponds to the correct answer.
int[] numList = new int[50];

for (int i = 0; i < 50; i++)


numList[i] = 2 * i;

num[10] = -20;
num[30] = 8;
a 1. What is the data type of the array numList above?
a. int c. list
b. new d. numList
d 2. How many components are in the array numList above?
a. 0 c. 49
b. 30 d. 50

c 3. What is the index number of the last component in the array numList above?

a. 0 c. 49
b. 30 d. 50
a 4. What is the value of numList.length in the array above?
a. 0 c. 49
b. 30 d. 50
a 5. What is the value at index 10 of the array numList?
a. -20 c. 20
b. 0 d. None of these
c 6. Consider the following statements:
int[] hits = {5, 7, 9, 11, 13, 15};
What is the number of elements in the array hits.
a. 0 c. 6
b. 5 d. 15

b 7. Which of the following declares an array of int named beta?


a. int beta; c. new int beta[];
b. int[] beta; d. int beta = int[];
d 8. What is the value of alpha[4] after the following code executes?
int[] alpha = new int[5];
for (int j = 0; j < 5; j++)
alpha[j] = 2 * j - 1;
a. 1 c. 5

b. 3 d. 7
c 9. What is the value of alpha[3] after the following code executes?
int[] alpha = new int[5];
alpha[0] = 3;
for (int j = 1; j < 5; j++)

alpha[j] = alpha[j – 1] + 3;
a. 3 c. 12
b. 6 d. 15
a 10. Which of the following creates an array of 15 components of type double?
(i) double[] numList = new double[15];
(ii) double[] numList = new numList[15];
a. Only (i) c. Both (i) and (ii)
b. Only (ii) d. None of these
b 11. Which of the following can be used as an array subscript?
a. char c. double
b. int d. String
c 12. If you declare an array as follows, how do you indicate the final element of the array?
int[] num = new int[6];
a. num[0] c. num[5]
b. num[6] d. impossible to tell

b 13. If you declare an integer array as follows, what is the value of num[2]?
int[] num = {101, 202, 303, 404, 505, 606};
a. 101 c. 202
b. 303 d. 404
b 14. In the following array, what is the value of address[1][1]?
String address = {{ “123 Artacho St.” , “345 Alvear St.”},
{ “87 New St.” , “901 Rizal St.” }}
a. “123 Artacho St.” c. “345 Alvear St.”
b. “87 New St.” d. “901 Rizal St.”
d 15. In the following array, what is the value of code[2][1]?
char[][] code = { {‘A’, ‘D’, ‘M’},
{‘P’, ‘R’, ‘S’},
{‘U’, ‘V’, ‘Z’}};
a. P c. R
b. U d. V

You might also like