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

Recursive 2D Array Traversal

Mark
< Prev
Next >

What is the output produced when the following program is executed?

public class TransposePrint {
    public static void printTranspose(int[][] arr, int col, int row) {
        if (col == arr[0].length) return;
        if (row == arr.length) {
            System.out.println();
            printTranspose(arr, col + 1, 0);
            return;
        }
        System.out.print(arr[row][col] + " ");
        printTranspose(arr, col, row + 1);
    }
    public static void main(String[] args) {
        int[][] mat = { {1, 2, 3}, {4, 5, 6} };
        printTranspose(mat, 0, 0);
    }
}
A

4 1
5 2
6 3

B

1 4 2 5 3 6

C

1 4
2 5
3 6

D

1 2 3 4 5 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.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|