logo Practice-It logo

BJP4 Self-Check 7.35: arrayMystery2d

Language/Type: Java 2D arrays array mystery
Author: Marty Stepp (on 2016/09/08)

Consider the following method:

public static void mystery2d(int[][] a) {
    for (int r = 0; r < a.length; r++) {
        for (int c = 0; c < a[0].length - 1; c++) {
            if (a[r][c + 1] > a[r][c]) {
                a[r][c] = a[r][c + 1];
            }
        }
    }
}

If a two-dimensional array named numbers is initialized to store the following integers, what are its contents after the call shown?

int[][] numbers = {
    {3, 4, 5, 6},
    {4, 5, 6, 7},
    {5, 6, 7, 8}
};
mystery2d(numbers);
numbers[0][0]
numbers[0][1]
numbers[0][2]
numbers[0][3]
numbers[1][0]
numbers[1][1]
numbers[1][2]
numbers[1][3]
numbers[2][0]
numbers[2][1]
numbers[2][2]
numbers[2][3]

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.