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: What does the following method do? public int question15()
{
Int value1 = 0;
Int value2 = 0;
For (int j = 0; j < 12; j++)
If (candy[j] > value1)
{
Value1 = candy[j];
Value2 = j;
}
Return value2;
}
A) It returns the total number of candy bars sold.
B) It returns the total number of children who sold zero candy bars.
C) It returns the total number of children who sold more than zero candy bars.
D) It returns the number of candy bars sold by the child who sold the most candy bars.
E) It returns the index of the child who sold the most candy bars.
Correct Answer:

Verified
Correct Answer:
Verified
Q1: Java arrays can store primitive types and
Q2: A polygon object in Java is<br>A) a
Q3: Code Example Ch 08-2<br>Assume you have an
Q4: The length operator can be used to
Q5: An array, when instantiated, is fixed in
Q7: The class Name consists of 4 instance
Q8: An array index cannot be a float,
Q9: Code Example Ch 08-1<br>Assume an int array,
Q10: Code Example Ch 08-1<br>Assume an int array,
Q11: Write a method to output all elements