Search Header Logo

WTN-12-QUIZ-3

Authored by arunasri pabbisetti

Computers

University

Used 5+ times

WTN-12-QUIZ-3
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?