Questions: Two-Dimensional Arrays

4 questions to test your understanding

Score: 0 / 4
Question 1 Multiple Choice

In Java, after `int[][] m = new int[3][5];`, what are the values of m.length and m[0].length?

A15 and 5
B3 and 5
C5 and 3
D3 and 15
Question 2 Multiple Choice

What does this Python code print? grid = [[0] * 3] * 2 grid[0][0] = 7 print(grid)

A[[7, 0, 0], [0, 0, 0]]
B[[7, 0, 0], [7, 0, 0]]
C[[7, 7, 7], [0, 0, 0]]
DAn IndexError
Question 3 True / False

In a row-major traversal of a 2D array, the outer loop runs over the columns and the inner loop runs over the rows.

TTrue
FFalse
Question 4 Short Answer

Write a Java loop (or describe one precisely) that computes the sum of column 2 of a rectangular int[][] array named grid.

Think about your answer, then reveal below.