Free Version
Moderate

# Minimum and Maximum Array Values and Integer Class

APCSA-4MGPNL

Consider the following methods to determine the minimum and maximum bowling scores from a list.

    // Precondition: scores is filled with valid scores.
// Precondition: There is at least one score in scores.
public int minScore(int[ ] scores)
{
// define variable min here

for (i=0; i<scores.length; i++)
{
if (scores[i] < min)
min = scores[i];
}
return min;
}

//Precondition: scores is filled with valid scores.
//Precondition: There is at least one score in scores.
public int maxScore(int[] scores)
{
// define variable max here

for  (i=0; i<scores.length; i++)
{
if (scores[i] > max)
max = scores[i];
}
return max;
}


Which of the following would be a good way to declare and initialize the min and max variables in their respective methods?

A
int min = Integer.MIN_VALUE;
int max = Integer.MIN_VALUE;

B
int min = Integer.MAX_VALUE;
int max = Integer.MAX_VALUE;

C
int min = 0;
int max = 300;

D
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;

E
int min = Integer.MIN_VALUE;
int max = Integer.MAX_VALUE;