WTN-12-QUIZ-3

WTN-12-QUIZ-3

University

10 Qs

quiz-placeholder

Similar activities

Unit-2: Assignment 2

Unit-2: Assignment 2

University

15 Qs

NumpyPandas

NumpyPandas

University

10 Qs

Array 2: Unit 8

Array 2: Unit 8

University

6 Qs

Arrays and Functions

Arrays and Functions

University

12 Qs

JAVA array

JAVA array

12th Grade - University

10 Qs

Weekly Contest #3 - TechXNinjas

Weekly Contest #3 - TechXNinjas

University

10 Qs

training ep.2

training ep.2

University

11 Qs

Prob. prog 2

Prob. prog 2

University

10 Qs

WTN-12-QUIZ-3

WTN-12-QUIZ-3

Assessment

Quiz

Computers

University

Hard

Created by

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?