CAI710: WQ1

CAI710: WQ1

12th Grade

8 Qs

quiz-placeholder

Similar activities

Java for Geeks and Dummies

Java for Geeks and Dummies

12th Grade - University

10 Qs

2D Arrays in Java (Review)

2D Arrays in Java (Review)

12th Grade

8 Qs

Y6 - Programming A - Variables in games

Y6 - Programming A - Variables in games

6th Grade - University

10 Qs

Lecture 4.4 Part 2

Lecture 4.4 Part 2

12th Grade

11 Qs

Javascript Arrays

Javascript Arrays

9th - 12th Grade

12 Qs

CSP Unit 3 Data Representation

CSP Unit 3 Data Representation

9th - 12th Grade

10 Qs

AP Review Quiz #2

AP Review Quiz #2

9th - 12th Grade

10 Qs

AP CSA Inheritance Polymorphism

AP CSA Inheritance Polymorphism

10th - 12th Grade

8 Qs

CAI710: WQ1

CAI710: WQ1

Assessment

Quiz

Computers

12th Grade

Hard

Created by

Ayesha Abdullah

Used 65+ times

FREE Resource

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

What are the contents of mat after the code segment has been executed?

Media Image
Media Image
Media Image
Media Image
Media Image

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

A two-dimensional array arr is to be created with the following contents.


boolean[][] arr = {{false, true, false} ,

{false, false, true}};


Which of the following code segments can be used to correctly create and initialize arr ?

boolean arr[][] = new boolean[2][3];

arr[0][1] = true;

arr[1][2] = true;

boolean arr[][] = new boolean[2][3];

arr[1][2] = true;

arr[2][3] = true;

boolean arr[][] = new boolean[3][2];

arr[0][1] = true;

arr[1][2] = true;

boolean arr[][] = new boolean[3][2];

arr[1][0] = true;

arr[2][1] = true;

boolean arr[][] = new boolean[3][2];

arr[2][1] = true;

arr[3][2] = true;

3.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Consider the following code segment, which is intended to declare and initialize the two-dimensional (2D) String array things.

/* missing code */ = {{"spices", "garlic", "onion", "pepper"},

{"clothing", "hat", "scarf", "gloves"},

{"plants", "tree", "bush", "flower"},

{"vehicles", "car", "boat", "airplane"}};

Which of the following could replace /* missing code */ so that things is properly declared?

new String[][] things

new(String[][]) things

String[] String[] things

String[][] things

[][]String things

4.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Consider the following code segment.

int[][] array2D = {{1, 2, 3, 4},

{5, 6, 7, 8},

{9, 10, 11, 12},

{13, 14, 15, 16}};


for (int[] i : array2D){

for (int x : i){

System.out.print(x + " ");

}

System.out.println(" ");

}

How many times will the statement System.out.print(x + " ") be executed?

3 times

4 times

6 times

12 times

16 times

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Assume that a two-dimensional (2D) array arr of String objects with 3 rows and 4 columns has been properly declared and initialized.

Which of the following can be used to print the elements in the four corner elements of arr ?

System.out.print(arr[0, 0] + arr[0, 3] + arr[2, 0] + arr[2, 3]);

System.out.print(arr[1, 1] + arr[1, 4] + arr[3, 1] + arr[3, 4]);

System.out.print(arr[0][0] + arr[0][2] + arr[3][0] + arr[3][2])

System.out.print(arr[0][0] + arr[0][3] + arr[2][0] + arr[2][3]);

System.out.print(arr[1][1] + arr[1][4] + arr[3][1] + arr[3][4]);

6.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Consider the following code segment, where letters is a two-dimensional (2D) array that contains possible letters. The code segment is intended to print "DIG".


String[][] letters = {{"A", "B", "C"},

{"D", "E", "F"},

{"G", "H", "I"}};


System.out.println( /* missing code */ );

Which of the following could replace /* missing code */ so that the code segment works as intended?

letters[1][0] + letters[2][2] + letters[2][0]

letters[2][1] + letters[3][3] + letters[3][1]

letters[2][0] + letters[2][2] + letters[1][0]

letters[1][2] + letters[3][3] + letters[1][3]

letters[0][1] + letters[2][2] + letters[0][2]

7.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Consider the following code segment, where nums is a two-dimensional (2D) array of integers. The code segment is intended to print "test1234".

System.out.print("test" + nums[0][0] + nums[1][0] + nums[1][1] + nums[0][1]);


Which of the following code segments properly declares and initializes nums so that the code segment works as intended?

int[][] nums = {{1, 2}, {3, 4}};

int[][] nums = {{1, 4}, {2, 3}};

int[][] nums = {{1, 2}, {4, 3}};

int[][] nums = {{1, 3}, {2, 4}};

int[][] nums = {{1, 4}, {3, 2}};

8.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Consider the following code segment.

int[][] arr = {{1, 2, 3},

{4, 5, 6},

{7, 8, 9},

{3, 2, 1}};

for (int j = 0; j < arr.length; j++){

for (int k = j; k < arr[0].length; k++){

System.out.print(arr[j][k] + " ");

}

System.out.println();

}

What output is printed when the code segment is executed?

2 3

6

1 2 3

4 5

7

1 2 3

5 6

9

1 4 7

5 8

9

1 2 3

5 6

9

1