| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice TestPractice Test
Share
About Exam
medium Solved by 4 students
Modifying Primitives in an Enhanced For-Loop
< Prev
Next >

What does the code print when executed?

public class ModifyMatrix {
    public static void main(String[] args) {
        int[][] matrix = { {1,2}, {3,4} };
        for (int[] row : matrix) {
            for (int n : row) {
                n = n + 5;
            }
        }
        System.out.print(matrix[0][0] + " " + matrix[1][1]);
    }
}
A

1 9

B

1 4

C

6 9

D

6 4

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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