quiz 6

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

Subscript numbering always starts at what value?

0

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 = 100; for(int i = 0; i < SUB; i++) { x[i] = y; y += 10; }

180

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

What is the value of 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

What do you normally use with a partially-filled array?

An accompanying integer value that holds the number of items stored in the array

What will be the results of the following code? final int ARRAY_SIZE = 5; double[] x = new double[ARRAY_SIZE]; for(int i = 1; i <= ARRAY_SIZE; i++) { x[i] = 10.0; }

An error will occur when the program runs.

What would be the results of the following code? int[] array1 = new int[25]; ... // Code that will put values in array1 int value = array1[0]; for (int a = 1; a < array1.length; a++) { if (array1[a] < value) value = array1[a]; }

Value contains the lowest value in array1.

It is common practice to use a ________ variable as a size declarator.

final

Each array in Java has a public field named ________ that contains the number of elements in the array.

length

To return an array of long values from a method, use this as the return type for the method.

long[]

In order to do a binary search on an array:

the array must first be sorted in ascending order

This indicates the number of elements, or values, the array can hold.

the array's size declarator

Java performs ________, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.

array bounds checking

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[2] > x[5]) a = 5; else a = 8;

a = 5

A ragged array is:

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


Ensembles d'études connexes

Contemporary Biology - Quiz 9-11

View Set

Art 100 Ch 15 Christianity and the Formation of Europe

View Set

Astronomy Part 4 Reading Assignments

View Set

ch8: data warehouse and data mart modeling

View Set

SEC.6 real estate contract law unit.1

View Set