Chapter 8: Arrays & ArrayLists

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Given that String[ ] str has been initialized, to get a copy of str[0] with all characters converted to uppercase, use the following statement: a) str.uppercase( ); b) str[0].upperCase( ); c) str.toUpperCase( ); d) str[0].toUpperCase( );

D

When an array is passed to a method: a) reference to the array is passed b) it is passed just as an object c) the method has direct access to the original array d) all of the above

D

The last subscript in an array is always: a) 100 b) -1 c) 0 d) 1 less than the number of elements

D

What does the following statement do? double[ ] array1 = new double[10]; a) Declares array1 to be a reference to an array of double values b) Creates an instance of an array of 10 double values c) Will allow valid subscripts in the range of 0-9 d) All of the above

D

An array's size declaratory can be a negative number. True/False

False

Java does not allow a statement to use a subscript that is outside the range of valid subscripts for an array. True/False

False

When an array is passed to a method, the method has access only to a copy of the original array. True/False

False

An ArrayList automatically expands in size to accommodate the items saved in it. True/False

True

In an array declaration, this indicates the number of elements that the array will have: a) Subscript b) Size Declarator c) element sum d) reference variable

B

In order to do a binary search on an array: a) the values of the array must be numeric b) the array must first be sorted in ascending order c) you must first do a sequential search of the array to assure the element you are looking for is there d) there are no requirements

B

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. a) active array sequencing b) array bounds checking c) scope resolution binding d) buffer overrun protection

B

The first subscript in an array is always: a) 1 b) 0 c) -1 d) 1 less than the number of the elements

B

This search algorithm steps through an array, comparing each item with the search value, starting at the beginning of the array: a) Binary search b) Sequential search c) Selection search d) iterative search

B

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; } a) 170 b) 180 c) 190 d) 200

B

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; a) x[ ] = {36, 78, 12, 24} and y[ ] = {23, 55, 83, 19} b) x[ ] = {36, 78, 12, 24} and y[ ] = {36, 78, 12, 24} c) x[ ] = {23, 55, 83, 19} and y[ ] = {23, 55, 83, 19} d) This is a compilation error.

B

Array bounds checking happens: a) When the program is compiled b) When the program is loaded into memory c) When the program is run d) When the program is saved

C

If final int SIZE = 15 and int[ ] x = new int[SIZE], what would be the range of subscript values that could be used with x[ ]? a) 1 through 15 b) 1 through 14 c) 0 through 14 d) 0 through 15

C

Each element of an array is accessed by a number known as a(n): a) Subscript b) Address c) address d) specifier

A

This search algorithm requires a sorted array: a) Binary search b) Sequential search c) Selection search d) iterative search

A

What do you call the number that is used as an index to pinpoint a specific element within an array? a) subscript b) global unique identifier c) element d) argument

A

The sequential search algorithm: a) requires the array to be ordered b) must always be implemented as a method c) uses a loop to sequentially step through an array, starting with the first element d) will not execute, if the element is not in the array

C

This array field holds the number of elements that the array contains: a) Size b) Elements c) length d) width

C

To insert an item at a specific location in an ArrayList object, you use this method: a) Store b) Insert c) add d) get

C

Both of these statements are legal and equivalent.: int [ ] numbers; int numbers [ ]; True/False

True

The Java compiler does not display an error message when it processes a statement that uses an invalid subscript. True/False

True

The subscript of the last element in a single-dimensional array is one less than the total number of elements in an array. True/False

True

The values in an initialization list are stored in the array in the order that they appear. True/False

True


Set pelajaran terkait

Yearbook Copy: Traditional Copy records the event of the year

View Set

Practice Guidelines on Nonrestorative Treatments for Carious Lesions

View Set

Communication and Interpersonal Relationship Practice Questions

View Set

Financial Accounting Tools for Decision Making Chapter 3

View Set

Science - Chapter 7.1-7.8 and 8.1-8.7

View Set

Cognitive Psychology Book Questions Chapter 5

View Set

1.4. Моделювання баз даних в процесі проектування

View Set