The following incomplete method is intended to return the largest integer in the array numbers.
// precondition: numbers.length > 0
public static int findMax(int[]numbers)
{
int posOfMax = O;
for (int index = 1; index < numbers.length; index++)
{
if ( /*condition*/ )
{
/* statement */
}
}
return numbers[posOfMax];
}
Which of the following can be used to replace /* condition */ and /* statement */ so that findMax will work as intended?
A
/* condition */ /* statement */
numbers[index] > numbers[posOfMax] posOfMax = numbers[index];
B
/* condition */ /* statement */
numbers[index] > numbers[posOfMax] posOfMax = index;
C
/* condition */ /* statement */
numbers[index] > posOfMax posOfMax = numbers[index];
D
/* condition */ /* statement */
numbers[index] < posOfMax posOfMax = numbers[index];
E
/* condition */ /* statement */
numbers[index] < numbers[posOfMax] posOfMax = index;