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

2D Array Nested Loop Output

Mark
< Prev
Next >

What is printed as a result of executing the following code segment?

int [][] matrix = {{1, 1, 1}, {2, 2, 2}, {3, 3, 3}};
for (int i = 0; i < matrix.length; i++)
  for (int j = 0; j < matrix[i].length; j++)
     System.out.print(matrix[i][j] * 2 + " ");
System.out.print("\n");
A

2 2 2 4 4 4 6 6 6

B

2 4 6 2 4 6 2 4 6

C

2 2 2
4 4 4
6 6 6

D

A runtime error occurs.

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|