Multiple Choice
Code Example Ch 08-2
Assume you have an int array, candy, which stores the number of candy bars sold by a group of children where candy[j] is the number of candy bars sold by child j. Assume there are 12 children in all.
-Refer to Code Example Ch 08-2: Which of the following could be used to compute the total number of bars sold by the children?
A) for (int j=0; j<12; j++) sum += candy[j];
B) for (int j=0; j<12; j++) candy[j] = sum;
C) for (int j=0; j<12; j++) sum = candy[j];
D) for (int j=0; j<12; j++) sum += [j];
E) for (int j=0; j<12; j++) [j] += sum;
Correct Answer:

Verified
Correct Answer:
Verified
Q14: It is possible to sort an array
Q15: A Java main method uses the parameter
Q16: Arrays have a built-in toString method that
Q17: How can you tell if a user
Q18: If int[] x = new int[15]; and
Q20: What does the following statement do? int[]
Q21: Assume list is an array of int
Q22: A ragged array is a multidimensional array
Q23: Given the following code and assuming list
Q24: Which of the following is a legal