Chapter 7

¡Supera tus tareas y exámenes ahora con Quizwiz!

What does the following statement do? declares array1 to be a reference to an array of double values will allow valid subscripts in the range of 0 through 9 creates an instance of an array of 10 double values All of these

All of these

An array of String objects is arranged the same as an array of primitive objects. is compressed to 4 bytes for each element. must be initialized when the array is declared. consists of an array of references to String objects.

is arranged the same as an array of primitive objects.

Java provides a mechanism known as ________, which makes it possible to write a method that takes a variable number of arguments. variable-length argument lists dynamic parameter lists unary-signature templates polymorphic byte codes

variable-length argument lists

For the following code, what would be the value of str[2]? String[] str = ("abc" , "def", "ghi", "jkl"); a reference to the String object containing "ghi" "ghi" a reference to the String object containing "def" "def"

"def"

What is the value of scores[2][3] in the following array? 95 84 94 93

93

When an array is passed to a method it is passed just as any other object would be. the method has direct access to the original array. a reference to the array is passed. All of these

All of these

Which of the statements are true about the following code? final int ARRAY_SIZE = 10; long [] array1 = new long [Array_SIZE]; declares array1 to be a reference to an array of long values creates an instance of an array of 10 long values will allow valid subscripts in the range of 0 through 9 All of these

All of these

The sequential search algorithm returns 1 if the value being search for is found, otherwise it returns -1. requires the array to be in ascending ordered. uses a loop to sequentially step through an array, starting with the first element. All of these

uses a loop to sequentially step through an array, starting with the first element.

A search algorithm arranges elements in ascending order. arranges elements in descending order. is used to locate a specific item in a larger collection of data. is rarely used with arrays.

is used to locate a specific item in a larger collection of data

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

long[ARRAY_SIZE] WRONG

You can use the ________ method to replace an item at a specific location in an ArrayList. set remove replace add

set

In order to do a binary search on an array, the array must first be sorted in ascending order. you must first do a sequential search of the array to assure the element you are looking for is there. the values of the array must be numeric. All of these

the array must first be sorted in ascending orde

Given the following two-dimensional array declaration, which statement is true? int [] [] numbers n= new int [6] [9] The numbers array has 54 rows. The numbers array has 15 rows. The numbers array has 6 rows and 9 columns. The numbers array has 6 columns and 9 rows.

The numbers array has 6 rows and 9 columns.

Any items typed on the command-line, separated by space, after the name of the class are considered to be one or more arguments that are to be passed into the main method.

True

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

True

When an array of objects is declared, but not initialized, the array values are set to 0. True False

True

This method returns a string representing all of the items stored in an ArrayList object. show toString print getList

getList WRONG

ou can use this ArrayList class method to insert an item at a specific location in an ArrayList. set store add insert

insert WRONG

A sorting algorithm is used to locate a specific item in a larger collection of data. True False

False

Objects in an array are accessed with subscripts, just like any other data type in an array. True False

True

The following import statement is required to use the ArrayList class: import java.util.Tools; import java.util.ArrayList; import java.util.Containers; import java.util.API

import java.util.ArrayList;

An array of String objects is arranged the same as an array of primitive objects. is compressed to 4 bytes for each element. must be initialized when the array is declared. consists of an array of references to String objects.

must be initialized when the array is declared.

The ________ method removes an item from an ArrayList at a specific index. remove pop deleteAt clear

remove

A(n) ________ is used as an index to pinpoint a specific element within an array. element range boolean value subscript

element

What will be the result of the following code? int [] numbers = {40, 3, 5 ,7 ,8 12, 10}; int value = numbers [0]; for (int i =1; i<numbers.length;i++) { if (numbers[i] < value) value = number[i]; } The value variable will contain the average of all the values in the numbers array. The value variable will contain the sum of all the values in the numbers array. The value variable will contain the lowest value in the numbers array. The value variable will contain the highest value in the numbers array.

The value variable will contain the lowest value in the numbers array.

Which of the following is a valid declaration for a ragged array with five rows, but no columns? int[][] ragged = new int[5]; int[][] ragged = new int[][5]; int[][] ragged = new int[5][]; int[] ragged = new int[5];

int[] ragged = new int[5];


Conjuntos de estudio relacionados

NU 313-01, Chapter 20- Nursing Management of the Pregnancy at Risk, Chapter 20- maternity, Chapter 19- Nursing Management of Pregnancy at Risk- Pregnancy

View Set

Chapter 27; Fluids and Electrolyte Balance

View Set

10,11,12,24 chp test 3 business law

View Set

Ethics chapter 1 Ethics and the Examined Life

View Set