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
hard Solved by 1 students

Recursive 2D Array Traversal

Mark
< Prev
Next >

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

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

1 2 3 4

B

1 4 3 2

C

4 3 2 1

D

4 2 3 1

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|