| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice TestPractice Test
About Exam
hard Solved by 1 students
Recursive 2D Array Traversal
< Prev
Next >

What is printed when the following program is executed?

public class MultiplyPrint {
    public static void printMultiplied(int[][] arr, int i, int j, int factor) {
        if (i == arr.length) return;
        if (j == arr[i].length) {
            System.out.println();
            printMultiplied(arr, i + 1, 0, factor);
            return;
        }
        System.out.print(arr[i][j] * factor + " ");
        printMultiplied(arr, i, j + 1, factor);
    }
    public static void main(String[] args) {
        int[][] grid = { {1, 2}, {3, 4} };
        printMultiplied(grid, 0, 0, 2);
    }
}
A

2 4
8 6

B

2 4 6 8

C

2 4
6 8

D

1 2
3 4

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1theofanusmischa11 1m 24s 16
#2vempaami00001 0m 00s -10
#3gopangjan89301 0m 06s -16
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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