Static 1D & 2D Arrays
Static 1D & 2D Arrays
Static 1D & 2D Arrays
(A) object
(B) record
### (C) array
(D) file
03. An array is a
### (A) data structure with one, or more, elements of the same type.
(B) data structure with LIFO access.
(C) data structure, which allows transfer between internal and external storage.
(D) data structure with one, or more, elements, called fields, of the same or different data types.
04. A record is a
(A) data structure with one, or more, elements of the same type.
(B) data structure with LIFO access.
(C) data structure, which allows transfer between internal and external storage.
### (D) data structure with one, or more, elements, called fields, of the same or different data types.
Exposure Java 2013, APCS Edition Chapter 10 Test Page 1 Updated: 05-16-13
05. A file is a
(A) data structure with one, or more, elements of the same type.
(B) data structure with LIFO access.
### (C) data structure, which allows transfer between internal and external storage.
(D) data structure with one, or more, elements, called fields, of the same or different data types.
06. A stack is a
(A) data structure with one, or more, elements of the same type.
### (B) data structure with LIFO access.
(C) data structure, which allows transfer between internal and external storage.
(D) data structure with one, or more, elements, called fields, of the same or different data types.
08. The array was first introduced by the __________ programming language.
Exposure Java 2013, APCS Edition Chapter 10 Test Page 2 Updated: 05-16-13
Objective 2 - One-Dimensional Array Declaration and Access
int list[ ];
list = new int[100];
(A) 99
### (B) 100
(C) 101
(D) 100 initial integers plus any additional integers required during program execution
Segment1 Segment2
Which of the following is a true statement about the comparison of Segment1 and Segment2?
double grades[ ];
grades = new double[50];
What is the index range capable of accessing an element of the grades array?
Exposure Java 2013, APCS Edition Chapter 10 Test Page 3 Updated: 05-16-13
Objective 3 - Accessing Elements In An Array
### (A) 0 0 0 0 0 0 0 0 0 0
(B) 0 1 2 3 4 5 6 7 8 9
(C) 1 2 3 4 5 6 7 8 9 10
(D) 0 0 0 0 0 0 0 0 0
(A) QQQQQQ
(B) Q R S T U
### (C) Q Q Q Q Q
(D) QQQQQ
Exposure Java 2013, APCS Edition Chapter 10 Test Page 4 Updated: 05-16-13
14. What is the output of program Java1014.java below?
(A) list[0] = 0
list[1] = 1
list[2] = 2
list[3] = 3
list[4] = 4
(B) list[0] = 1
list[1] = 2
list[2] = 3
list[3] = 4
list[4] = 5
(C) list[1] = 1
list[2] = 2
list[3] = 3
list[4] = 4
list[5] = 5
Exposure Java 2013, APCS Edition Chapter 10 Test Page 5 Updated: 05-16-13
15. What is the output of program Java1015.java below?
(A) list[0] = 0
list[1] = 1
list[2] = 2
list[3] = 3
list[4] = 4
(B) list[0] = 1
list[1] = 2
list[2] = 3
list[3] = 4
list[4] = 5
(C) list[1] = 1
list[2] = 2
list[3] = 3
list[4] = 4
list[5] = 5
(D) list[1] = 2
list[2] = 3
list[3] = 4
list[4] = 5
Exposure Java 2013, APCS Edition Chapter 10 Test Page 6 Updated: 05-16-13
16. What is the output of program Java1016.java below?
(B) list[5] = 5
list[4] = 4
list[3] = 3
list[2] = 2
list[1] = 1
(C) list[5] = 4
list[4] = 3
list[3] = 2
list[2] = 1
list[1] = 0
(D) list[4] = 1
list[3] = 2
list[2] = 3
list[1] = 4
Exposure Java 2013, APCS Edition Chapter 10 Test Page 7 Updated: 05-16-13
17. What is the FIRST and LAST output from this program segment?
18. What is the FIRST and LAST output from this program segment?
19. What is the FIRST and LAST output from this program segment?
Exposure Java 2013, APCS Edition Chapter 10 Test Page 8 Updated: 05-16-13
Objective 4 – Initialized Arrays and length
21. What is the output of the first println? 22. What is the output of the second println?
23. What is the output of the third println? 24. What is the output of the fourth println?
Exposure Java 2013, APCS Edition Chapter 10 Test Page 9 Updated: 05-16-13
Objective 5 – Random Array Elements
import java.util.Random;
Exposure Java 2013, APCS Edition Chapter 10 Test Page 10 Updated: 05-16-13
18. 26. What can be determined about the contents of the list array?
import java.util.Random;
(A) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then every element of the list array is
changed to a random value in the [0..9] range.
### (B) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then random elements of the list array are
changed to the current value of k.
(C) The original list array contains {0,1,2,3,4,5,6,7,8,9} and stays unchanged throughout the
program execution.
(D) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then random elements of the list array are
changed to random values.
(E) Without knowing the seed value of the Random object, nothing can be stated about the values
of any element in the list array.
Exposure Java 2013, APCS Edition Chapter 10 Test Page 11 Updated: 05-16-13
18. 27. What can be determined about the contents of the list array?
import java.util.Random;
### (A) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then every element of the list array is
changed to a random value in the [0..9] range.
(B) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then random elements of the list array are
changed to the current value of k.
(C) The original list array contains {0,1,2,3,4,5,6,7,8,9} and stays unchanged throughout the
program execution.
(D) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then random elements of the list array are
changed to random values.
(E) Without knowing the seed value of the Random object, nothing can be stated about the values
of any element in the list array.
Exposure Java 2013, APCS Edition Chapter 10 Test Page 12 Updated: 05-16-13
18. 28. What can be determined about the contents of the list array?
import java.util.Random;
(A) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then every element of the list array is
changed randomly to a value in the [0..9] range.
(B) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then random elements of the list array are
changed to the current value of k.
(C) The original list array contains {0,1,2,3,4,5,6,7,8,9} and stays unchanged throughout the
program execution.
(D) The original list array contains {0,1,2,3,4,5,6,7,8,9} and then the first five elements of the list
array are changed to random values.
### (E) The last four elements of the list array remain unchanged with values 6,7,8,9.
Exposure Java 2013, APCS Edition Chapter 10 Test Page 13 Updated: 05-16-13
Objective 6 - Accessing Array Elements with the Enhanced For Loop
30. Which of the following statement displays the list elements correctly?
31. Rewrite the old for loop program segment below with the new for loop.
(D) This program segment cannot be converted to the new for loop.
Exposure Java 2013, APCS Edition Chapter 10 Test Page 14 Updated: 05-16-13
32. Rewrite the old for loop program segment below with the new for loop.
### (D) This program segment cannot be converted to the new for loop.
33. Which of the following statements correctly declares a two-dimensional integer array?
Exposure Java 2013, APCS Edition Chapter 10 Test Page 15 Updated: 05-16-13
34. What is the output of the program below?
double mambo[ ][ ];
mambo = new double[4][5];
int r; // row index on mambo
int c; // column index of mambo
(A) mambo.length
(B) mambo.rowLength
(D) mambo[c].length
Exposure Java 2013, APCS Edition Chapter 10 Test Page 16 Updated: 05-16-13
36. What is the output of the program below?
double mambo[ ][ ];
mambo = new double[4][5];
int r; // row index on mambo
int c; // column index of mambo
(B) mambo.rowLength
(C) mambo[r].length
(D) mambo[c].length
Exposure Java 2013, APCS Edition Chapter 10 Test Page 17 Updated: 05-16-13
Use the program below for questions 38-40. Each question will provide a different implementation of
the createSquare method. The output shown is formatted for ease of reading. Technically, the
columns will not line up so nicely.
Exposure Java 2013, APCS Edition Chapter 10 Test Page 18 Updated: 05-16-13
38. What will be the output of program Java3840.java with the createSquare implementation below?
(A) 0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
### (B) 1 2 3 4 5
0 1 2 3 4
0 0 1 2 3
0 0 0 1 2
0 0 0 0 1
(C) 0 0 0 0 1
0 0 0 1 2
0 0 1 2 3
0 1 2 3 4
1 2 3 4 5
(D) 1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
Exposure Java 2013, APCS Edition Chapter 10 Test Page 19 Updated: 05-16-13
39. What will be the output of program Java3840.java with the createSquare implementation below?
### (A) 0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
(B) 1 2 3 4 5
0 1 2 3 4
0 0 1 2 3
0 0 0 1 2
0 0 0 0 1
(C) 0 0 0 0 1
0 0 0 1 2
0 0 1 2 3
0 1 2 3 4
1 2 3 4 5
(D) 1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
Exposure Java 2013, APCS Edition Chapter 10 Test Page 20 Updated: 05-16-13
40. What will be the output of program Java3840.java with the createSquare implementation below?
(A) 1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25
(B) 11 18 25 2 9
10 12 19 21 3
4 6 13 20 22
23 5 7 14 16
17 24 1 8 15
### (C) 17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
(D) 1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
Exposure Java 2013, APCS Edition Chapter 10 Test Page 21 Updated: 05-16-13
Objective 8 - Storing Objects in a Static Array
Use the class and program segment below for questions 41-42.
class Student
{
private String name;
private int age;
41. The relationship between the Students object and the Student objects is an example of
(A) inheritance.
(B) an initializer list.
### (C) composition.
(D) nested arrays.
Exposure Java 2013, APCS Edition Chapter 10 Test Page 22 Updated: 05-16-13
42. Which of the following describes the relationship of the objects?
### (A) The program uses a Students array object of Student objects.
(B) The program uses a Student array object of Students objects.
(C) The program uses a Student object of Student array objects.
(D) The program uses a Students object of Students array objects.
Use the class and program segment below for questions 43-44.
class MyList
{
private int intArray[];
private int size;
public MyList(int s)
{
intArray = new int[size];
}
}
43. Describes the result of executing the statement MyList list = new MyList(10);
Exposure Java 2013, APCS Edition Chapter 10 Test Page 23 Updated: 05-16-13
Objective 9 - Two-Dimensional Arrays and length
(This topic was also included in the earlier two-dimensional array section; this is a strict focus on length)
Which of the following statements will assign the correct size to rowSize?
Which of the following statements will assign the correct size to colSize?
Exposure Java 2013, APCS Edition Chapter 10 Test Page 24 Updated: 05-16-13
47. Consider the following two-dimensional array declaration.
Which of the following statements will assign the correct size to colSize?
System.out.println(matrix[0].length);
Exposure Java 2013, APCS Edition Chapter 10 Test Page 25 Updated: 05-16-13
Objective 10 - Parameter Differences Between Simple Data Types and Arrays
### (A) 10 20
(B) 20 10
(C) 10 10
(D) 20 20
(E) 0 0
Exposure Java 2013, APCS Edition Chapter 10 Test Page 26 Updated: 05-16-13
50. Consider the following program.
(A) 3 4
(B) 4 3
(C) 4 5
### (D) 5 4
(E) ArrayIndexOutOfboundsException
Exposure Java 2013, APCS Edition Chapter 10 Test Page 27 Updated: 05-16-13