Multiple Choice
For the questions below, assume an int array, candy, 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.
-Which of the following code 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
Q11: Write a method to output all elements
Q28: The Mouse Events include<br>A) mousePressed, mouseReleased, mouseClicked,
Q29: If an int array is passed as
Q31: In the RubberLinesPanel example in the text
Q32: The Mouse Motion Events include<br>A) mousePressed, mouseReleased,
Q34: Consider the array declaration and instantiation: int[
Q35: In a two-dimensional array, both dimensions must
Q36: Write code fragment to swap the two
Q37: To swap the 3ʳᵈ and 4ᵗʰ elements
Q38: Implement an ItemListener so that a new