Page 372 - AP Computer Science A, 7th edition
P. 372
(D) 0, 6, 0, 4, 0, 0, 2 (E) 6, 4, 2, 0, 0, 0, 0
5. Consider this program segment:
for (int i = 2; i <= k; i++) if (arr[i] < someValue)
System.out.print(“SMALL”);
What is the maximum number of times that SMALL can be
printed?
(A) 0
(B) 1
(C) k – 1 (D) k – 2 (E) k
6. What will be output from the following code segment, assuming it is in the same class as the doSomething method?
int[] arr = {1, 2, 3, 4}; doSomething(arr); System.out.print(arr[1] + “ ”); System.out.print(arr[3]);
...
public void doSomething(int[] list) {
int[] b = list;
for (int i = 0; i < b.length; i++)
b[i] = i;
}
(A) 0 0 (B) 2 4 (C) 1 3 (D) 0 2 (E) 0 3