Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 3 students

Extracting a Column from a 2D Array

< Prev
Next >

Consider the following code segment.

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 is printed when the code segment is executed?

A

5 10 15

B

5 10 10

C

15 15 15

D

10 10 10

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki11 0m 00s 100
#2winstonhou110701 1m 00s -70
#3y.seong202712 13m 43s -733
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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