| 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
< Prev
Next >

Consider 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");

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

A

A runtime error occurs.

B

2 2 2
4 4 4
6 6 6

C

2 4 6 2 4 6 2 4 6

D

2 2 2 4 4 4 6 6 6

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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