How many columns does a have if it is created as follows
int[][] a = { {2, 4, 6, 8}, {1, 2, 3, 4}};?
WTN-12-QUIZ-3
Quiz
•
Computers
•
University
•
Hard
arunasri pabbisetti
Used 5+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How many columns does a have if it is created as follows
int[][] a = { {2, 4, 6, 8}, {1, 2, 3, 4}};?
2
4
8
16
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the index variable for the element at the first row and first column in array
a?
.
a[0][0]
a[1][1]
a[0][1]
a[1][0]
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
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).
strGrid[0][2] = "S";
strGrid[1][3] = "S";
strGrid[3][1] = "S";
strGrid[2][0] = "S";
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How would you get the value 6 out of the following array
int[][] a = { {2, 4, 6, 8}, {1, 2, 3, 4}};?
a[0][3]
a[1][3]
a[0][2]
a[2][0]
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
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]; }
4
8
9
12
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
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) mat[row][col] = 1; else if (row == col) mat[row][col] = 2; else mat[row][col] = 3; } }
{ {2 3 3}, {1 2 3}, {1 1 2}, {1 1 1}}
{ {2 1 1}, {3 2 1}, {3 3 2}, {3 3 3}}
{ {2 1 1 1}, {3 2 1 1}, {3 3 2 1}}
{ {2 3 3 3}, {1 2 3 3}, {1 1 2 3}}
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
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]; }
A. 4 B. 6 C. 9 D. 10
4
6
9
10
7 questions
Java arrays
Quiz
•
University
10 questions
IT Quiz Round 3
Quiz
•
University
13 questions
Revision 2 MCA
Quiz
•
University
15 questions
Round 1 (Tech Utsav)
Quiz
•
University
10 questions
BOOTSTRAP
Quiz
•
University
10 questions
Java Arrays
Quiz
•
University
12 questions
Arrays C++
Quiz
•
University
12 questions
Chapter 2-1: Array Part 1
Quiz
•
University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade