COSC 110

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Given the following array declaration: int[][] triangleArray = { {1, 2, 3, 4, 5}, {6, 7, 8, 9}, {10, 11, 12}, {13, 14}, {15}, }; What is the value of the following triangleArray [2][2]?

12

What will be the value of x[1] after the following code is executed? int[] x = {22, 33, 44} ; arrayProcess(x[1]); ... public static void arrayProcess(int a) { a = a + 5; }

33

What will be the value of x[1] after the following code is executed? int[] x = {22, 33, 44}; arrayProcess(x); ... public static void arrayProcess(int[] a) { for(int k = 0; k <3; k++) { a[k] = a[k] + 5; } }

38

Given the following array declaration: int[][] triangleArray = { {1, 2, 3, 4, 5}, {6, 7, 8, 9}, {10, 11, 12}, {13, 14}, {15}, }; What is the value of the following triangleArray [1][2]?

8

What is the value of scores [1][1] in the following array? int [][] scores = { {88, 80, 79, 92}, {75, 84, 93, 80} {98, 95, 92, 94}, {91, 84, 88, 96} };

84

What is the value of scores [3][2] in the following array? int [][] scores = { {88, 80, 79, 92}, {75, 84, 93, 80} {98, 95, 92, 94}, {91, 84, 88, 96} };

88

What is the output of the following code? int[][] array2 = { {1, 2}, {3, 4}, {5, 6} }; int sum = 0; for (int i = 0; i < array2.length; i++) sum += array2 [i][0]; System.out.println(sum);

9

What is the value of the scores [2][3] in the following array? int [][] scores = { {88, 80, 79, 92}, {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} };

94

An objects _________ is simply the data that is stored in the objects fields at any given moment.

State

Static methods can only operate on __________ fields.

Static

Which of the following is a correct method header for receiving a two-dimensional array as an argument?

B. public static void passArray(int [][])

What would be the results of the following code? int[] x = { 55, 33, 88, 22, 99, 11, 44, 66, 77}; int a = 10; if(x[a] > x[5]) a = 5; else a = 8;

a = 5

When a methods return type is a class, what is actually returned to the calling program?

a reference to an object of that class

A ragged array is:

a two-dimensional array where the rows are of different lengths.

A static field is created by placing:

the key word static after the access specifier and before the field's data type

What would be the results after the following code was executed? int[] x = {23, 55, 83, 19}; int[] y = {36, 78, 12, 24}; x = y; y = x;

x[] = {36, 78, 12, 24} and y[] = {36, 78, 12, 24}

What would be the results after the following code was executed? int[] x = {23, 55, 83, 19}; int[] y = {36, 78, 12, 24}; for (int a = 0; a < x.length; a++) { x[a] = y[a]; y[a] = x[a]; }

x[] = {36, 78, 12, 24} and y[] = {36, 78, 12, 24}

What is the value of scores [3][3] in the following array? int [][] scores = { {88, 80, 79, 92}, {75, 84, 93, 80} {98, 95, 92, 94}, {91, 84, 88, 96} };

96

Java automatically store this value in all uninitialized static member variable:

0

Given the following array declaration: int[][] triangleArray = { {1, 2, 3, 4, 5}, {6, 7, 8, 9}, {10, 11, 12}, {13, 14}, {15}, }; What is the value of the following triangleArray [2][1]?

11

What will be the value of x[8] after the following code has been executed? final int SUB = 12; int[] x = new int [SUB]; int y = 20; for(int i = 0; i < SUB; i++) { x[i] = y; y += 5; }

60

Given the following array declaration: int[][] triangleArray = { {1, 2, 3, 4, 5}, {6, 7, 8, 9}, {10, 11, 12}, {13, 14}, {15}, }; What is the value of the following triangleArray [1][1]?

7

What is the value of scores [1][3] in the following array? int [][] scores = { {88, 80, 79, 92}, {75, 84, 93, 80} {98, 95, 92, 94}, {91, 84, 88, 96} };

80

If object1 and object2 are objects of the same class, to make object2 a copy of object1:

B. write a copy method that will make a field by field copy of object1 data members into object2 data members

Which of the following is a valid declaration for a ragged array?

C. int [][] array1 = new int [5][];

To compare two objects in a class:

C. write an equals method that will make a field by field compare of the two objects

If numbers is a two-dimensional int array that has been initialized and total is an int that has been set to 0, which of the following will sum all the elements in the array?

D. for (int row = 0; row < numbers.length; row++) { for (int col = 0; col < number[row].length; col++) total += numbers[row][col]; }

If numbers is a two-dimensional array, which of the following would give the length row r?

D. numbers[r].length

The only limitation that static methods have is:

D. they cannot refer to non-static members of the class

When a field is declared static, there will be:

B. only one copy of the field in memory

When a reference variable is passed as an argument to a method:

B. the method has access to the object that the variable references

In order to do a binary search on an array:

the array must first be sorted into ascending order


Ensembles d'études connexes

PNC 2 PrepU - Chronic Kidney Disease - ML5

View Set

Chapter 6, Responsibilities in the Cloud

View Set

Religion: Bible (Gospel of John)

View Set

Module 1: Introduction to Networking

View Set

Biology - Skeletal, Muscular, Circulatory, & Respiratory System exam (Daniel)

View Set

week 11: reconceptualizing national cinemas

View Set

Principles of Financial Accounting

View Set