Exam weight Low
Exam weight Low
Exam weight Low
- int[][] matrix = new int[5][5]; matrix[0][0] = 3;
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight
High
- matrix.length = number of rows; matrix[0].length = columns of row 0.
🎯 How this can come up · 1 question
MCQ
For int[][] m = new int[3][4];, m.length and m[0].length are:
Correct: 3 and 4.
Exam weight Low
Exam weight
Medium
- Ragged arrays: rows of different lengths: new int[5][] then each row separately.
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
- Sum all: nested for over rows and columns.
Exam weight
High
- Column sums: outer loop over columns, inner over rows.
🎯 How this can come up · 1 question
Written
Write code that sums each column of int[][] m.
for (int c = 0; c < m[0].length; c++) { int total = 0; for (int r = 0; r < m.length; r++) total += m[r][c]; System.out.println(total); }
Exam weight Low
- Pass a 2D array: public static int sum(int[][] m).
Exam weight Low
- 3D arrays: double[][][] scores = new double[6][5][2];
Exam weight Low
No slides match this filter.