2026 QUESTIONS WITH ANSWERS
GRADED A+
◍ n-dimensional array.
Answer: A collection of a fixed number of elements (called components)
arranged in n dimensions (n>=1) is called a(n) ____.
◍ int[][]values = {{3,4,5,1},{33,6,1,2}}; int v=values[0][0]; for(int[] list:
values) for(int element: list) if (v>element) v=element; System.out.print(v);.
Answer: 1
◍ 0 11 22 3.
Answer: After the following statements execute, what are the contents of
matrix?int matrix[3][2];int j, k;for (j = 0; j < 3; j++) for (k = 0; k < 2; k++)
matrix[j][k] = j + k;
◍ How many elements are array matrix (int[][] matrix = new int[5][5])?.
Answer: 25
◍ Which of the following statements are correct?.
Answer: char[][] charArray = {{'a', 'b'}, {'c', 'd'}};
◍ True.
Answer: T/F?All components of an array are of the same data type.
◍ False.
Answer: T/F?Arrays can be passed as parameters to a function by value, but
it is faster to pass them by reference.
◍ 0 through 99.
Answer: Assume you have the following declaration char nameList[100];.
Which of the following ranges is valid for the index of the array nameList?
, ◍ 0 through 999.
Answer: Assume you have the following declaration double
salesData[1000];. Which of the following ranges is valid for the index of the
array salesData?
◍ beta[0].
Answer: Assume you have the following declaration int beta[50];. Which of
the following is a valid element of beta?a. beta['2'] b. beta['50'] c. beta[0] d.
beta[50]
◍ What is the index variable for the element at the first row and first column in
array a?.
Answer: a[0][0]
◍ public static void main(String[] args) { int[][][] data = {{{1,2},{3,4}},
{{5,6},{7,8}}}; System.out.print(ttt(data[0])); } public static int ttt(int
[][]m) { int v = m[0][0]; for(int i = 0; i<m.length; i++) for (int j = 0;
j<m[i].length; j++) if(v<m[i][j]) v=m[i][j]; return v; }.
Answer: 4
◍ int [][] matrix = new int[5][5]; for(int column = 0; column<matrix[4].length;
column++) matrix[4][column] = 10;.
Answer: After the loop, the last row of matrix 10, 10, 10, 10, 10.
◍ public static void main(String[] args) { double [][]m = {{1,2,3},
{1.5,2.5,3.5}, {0.1,0.1,0.1}}; System.out.println(sum(m)); } public static
double sum(double[][]m) { double sum = 0; for(int i = 0; i<m.length; i++)
sum+=m[i][i]; return sum; }.
Answer: 3.6
◍ When you create an array using the following statement, the element values
are automatically initialized to 0.int[][]matrix = new int[5][5];.
Answer: true
◍ Assume double[][] x = new double[4][5], what are x.length and
x[2].length?.