| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice TestPractice Test
About Exam
medium Solved by 12 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

15 15 15

B

5 10 15

C

10 10 10

D

5 10 10

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
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