2D Array Pracr
ticketInfo = new int [2][3];
seatingChart = new String[3][4]
How many elements are in ticketInfo?
Which of the following sets the value for the 3rd row and 2nd column of a 2D array called nums?
int[][] ticketInfo = { {25,20,25}, {25,20,25} };
String[][] seatingInfo = { {"Jamal", "Maria"}, {"Jake", "Suzy"}, {"Emma", "Luke"} };
What is the value at seatingInfo[2][1] after the code above exectues?
int[][] ticketInfo = { {25,20,25}, {25,20,25} };
String[][] seatingInfo = { {"Jamal", "Maria"}, {"Jake", "Suzy"}, {"Emma", "Luke"} };
int value = ticketInfo[1][0];
String name = seatingInfo[0][1];
What is the value of name after the code above executes?
How many rows does a have if it is created as follows int[][] a = { {2, 4, 6, 8}, {1, 2, 3, 4} };?
Which of the following would I use to get the value in the third row and second column from a 2D array called nums?
How many columns does a have if it is created as follows int[][] a = { {2, 4, 6, 8}, {1, 2, 3, 4} };?
Which of the following statements assigns the letter S to the third row and first column of a two-dimensional array named strGrid (assuming row-major order).
How would you get the value 6 out of the following array int[][] a = { {2, 4, 6, 8}, {1, 2, 3, 4} };?
Given the following code segment, what is the value of sum after this code executes?
int[][] matrix = { {1,1,2,2},{1,2,2,4},{1,2,3,4},{1,4,1,2} };
int sum = 0;
int col = matrix[0].length - 2;
for (int row = 0; row < 4; row++)
{
}
sum = sum + matrix[row][col]
What are the contents of mat after the following code segment has been executed?
int [][] mat = new int [4][3];
for (int row = 0; row < mat.length; row++) {
}
for (int col = 0; col < mat[0].length; col++) {
}
if (row < col) {
}
else if (row == col) {
}
else {
}
mat[row][col] = 1;
mat[row][col] = 2;
mat[row][col] = 3;
Given the following code segment, what is the value of sum after this code executes?
int[][] m = { {1,1,1,1},{1,2,3,4},{2,2,2,2},{2,4,6,8} };
int sum = 0;
for (int k = 0; k < m.length; k++) {
}
sum = sum + m[m.length-1-k][1];
What are the contents of arr after the following code has been executed?
int[][] arr = { {3,2,1},{1,2,3} };
int value = 0;
for (int row = 1; row < arr.length; row++) {
}
for (int col = 1; col < arr[0].length; col++) {
}
if (arr[row][col] % 2 == 1) {
}
if (arr[row][col] % 2 == 0) {
}
arr[row][col] = arr[row][col] + 1;
arr[row][col] = arr[row][col] * 2;
}
}
A two-dimensional array, imagePixels, holds the brightness values for the pixels in an image. The brightness can range from 0 to 255. What does the following method compute?
public int findMax(int[][] imagePixels) {
}
int r, c;
int i, iMax = 0;
for (r = 0; r < imagePixels.length; r++) {
}
for (c = 0; c < imagePixels[0].length; c++) {
}
i = imagePixels[r][c];
if (i > iMax)
iMax = i