Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice TestPractice Test
About Exam
easy Solved by 2 students

2D Array Column Maximum

Mark
< Prev
Next >

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[col][row]);

B

max = Math.max(max, data[row][col]);

C

max = Math.max(max, data[0][col]);

D

max = Math.max(max, data[data.length - 1][col]);

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|