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

Modifying Primitives in an Enhanced For-Loop

< Prev
Next >

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

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

6 9

C

1 4

D

6 4

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|