Array Minimum Value Initialization
The findMin method below is intended to return the smallest value in an integer array. Assume the array arr is not empty.
public static int findMin(int[] arr)
{
int min = /* some value */;
int index = 0;
while (index < arr.length){
if (arr[index] < min)
min = arr[index];
index++;
}
return min;
}
Which of the following can replace /* some value */ to ensure the method always correctly finds the minimum value?
I. Integer.MIN_VALUE
II. Integer.MAX_VALUE
III. arr[0]
A
I only
B
II only
C
III only
D
II and III only
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | hiboyshello | 2 | 2 | - | 200 |
| #2 | hridaansingal.174 | 1 | 1 | - | 100 |
| #3 | michael.2103ll | 0 | 1 | - | -10 |
| #4 | kwakmk090330 | 0 | 1 | - | -10 |
| #5 | test1111 | 0 | 1 | 0m 03s | -13 |
| #6 | mlhkrds | 0 | 1 | 0m 05s | -15 |
Items per page:
10
1 – 6 of 6
