2D Array Column Maximum
The following method is intended to return the maximum value in a specified column of a 2D integer array.
public int findMaxInColumn(int[][] data, int col) {
int max = Integer.MIN_VALUE;
for (int row = 0; row < data.length; row++) {
// missing code
}
return max;
}
Which code segment should replace // missing code for the method to work as intended?
A
max = Math.max(max, data[data.length - 1][col]);
B
max = Math.max(max, data[row][col]);
C
max = Math.max(max, data[col][row]);
D
max = Math.max(max, data[0][col]);
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE