Looks like no one added any tags here yet for you.
How do you create a 1D array?
int[] array = new int[5];
How do you create a 2D array?
int[][] matrix = new int[3][4];
What is the default value of array elements?
0 for numeric arrays, null for objects.
How do you initialize a 1D array with values?
int[] array = {1, 2, 3, 4, 5};
How do you initialize a 2D array with values?
int[][] matrix = {{1, 2, 3}, {4, 5, 6}};
How do you fill a 1D array with user input?
for (int i = 0; i < array.length; i++) { array[i] = scanner.nextInt(); }
How do you fill a 2D array with user input?
for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { matrix[i][j] = scanner.nextInt(); }}
How do you iterate through a 1D array to display elements?
for (int i = 0; i < array.length; i++) { System.out.println(array[i]); }
How do you iterate through a 2D array to display elements?
for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { System.out.print(matrix[i][j] + " "); } System.out.println(); }
How do you sum all elements in a 1D array?
int sum = 0; for (int num : array) { sum += num; }
How do you sum all elements in a 2D array?
int sum = 0; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { sum += matrix[i][j]; }}
How do you get the length of a 1D array?
array.length
How do you get the number of rows in a 2D array?
matrix.length
How do you get the number of columns in a 2D array?
matrix[i].length (for row i).
What is the index range for an array of size 5?
0 to 4.
How do nested loops work for a 2D array?
Outer loop = rows, Inner loop = columns.
What is the default value for uninitialized elements in an array?
0 for numbers, false for booleans, null for objects.
Can arrays hold objects in Java?
Yes.
.length in arrays represents what?
The total number of elements.
What is a ragged array?
A 2D array where rows have different lengths.