logo Practice-It logo

BJP3 Self-Check 7.31: arrayCodeTracing2d

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

What are the values of the elements in the array numbers after the following code is executed?

int[][] numbers = new int[3][4];
for (int r = 0; r < numbers.length; r++) {
    for (int c = 0; c < numbers[0].length; c++) {
        numbers[r][c] = r + c;
    }
}
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.