| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice Test
Share
medium Solved by 5 students
Extracting a Column from a 2D Array
< Prev
Next >

Consider the following client code and method:

int[][] grid = {{5,5,5},{10,10,10},{15,15,15}};
int[] arr = mystery(grid, 2);
for (int num : arr)
   System.out.print(num + " ");

public static int[] mystery(int[][] arr, int n)
{
   int[] m = new int[arr.length];
   for (int i = 0; i < arr.length; i++)
      m[i] = arr[i][n];
   return m;
}

What will be printed after the code executes?

A

10 10 10

B

5 10 15

C

5 10 10

D

15 15 15

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

Question Leaderboard

Not enough data yet to show leaderboard.

APFIVE © 2020.
Email: [email protected]|Privacy Policy