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
medium Solved by 2 students

2D Array Column Extraction

< Prev
Next >

Consider the following code segment.

int[][] numbers = {{10, 20, 30}, {40, 50, 60}, {70, 80, 90}, {100, 110, 120}};
int[] myArr = mystery(numbers, 1);
for (int j: myArr)
   System.out.print(j + " ");

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 as a result of executing the code segment?

A

40 50 60

B

10 40 70 100

C

20 60 80 110

D

20 50 80 110

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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