Chapter 7

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

You can use this ArrayList class method to insert an item at a specific location in an ArrayList. (Note: this should not replace another element but add itself to the list) A) store B) insert C) set D) add

Add

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

int[][] ragged = new int[5][];

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

long[]

Which class can be utilized to print an entire array (one dimension) quickly for testing purposes? Arrays Array Util Scanner

Arrays

Given the following two-dimensional array declaration, which statement is true? A) The numbers array has 6 columns and 9 rows. B) The numbers array has 54 rows. C) The numbers array has 6 rows and 9 columns. D) The numbers array has 15 rows.

The numbers array has 6 rows and 9 columns.

The trimToSize() method of the ArrayList class will return the following when called: (See the APIs if you are not sure!) an int -- the capacity of the list an int - the number of items in the list an int - the number of items removed from the list nothing, it is a void method

nothing, it is a void method

Which of the following is a correct method header for receiving a two-dimensional array as an argument? A) public static void passMyArray(int myArray) B) public static void passMyArray(int[][] myArray) C) public static void passMyArray(int[]myArray1, int[]myArray2) D) public static void passMyArray(array myArray)

public static void passMyArray(int[][] myArray)

The ________ method removes an item from an ArrayList at a specific index. A) clear B) pop C) remove D) deleteAt

remove

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

subscript

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

the array must first be sorted in ascending order.

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

variable-length argument lists

A partially filled array is normally used A) with an accompanying integer value that holds the number of items stored in the array. B) when a very small number of values need to be stored. C) with an accompanying parallel array. D) when you know how many elements will be in the array.

with an accompanying integer value that holds the number of items stored in the array.

For the following code, what would be the value of str[2]? A) a reference to the String object containing "ghi" B) a reference to the String object containing "def" C) "def" D) "ghi"

a reference to the String object containing "ghi"

What is a ragged array? A) a two-dimensional array for which the number of rows is unknown B) a two-dimensional array where the rows have a different number of columns C) a one-dimensional array for which the number of elements is unknown D) a partially initialized two-dimensional array of ranged values

a two-dimensional array where the rows have a different number of columns

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

consists of an array of references to String objects.

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

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

Given the following declaration and initialization, how would you reference 42? int[] [] life = {23, 34, 98}, {89, 33, 74}, {52, 42, 90}; life[2][1] life[2][2] life[1][2] life[3][2]

life[2][1]

Which method of the ArrayList class allows you to search for a particular object and, if it exists, removes the object from the list? Check the APIs if you are not sure. delete search findAndDelete remove

remove

What is the syntax for determining the number of columns in a row in a 2D array? Use the following array as an example: int[][] scores = new int[3][]; scores[0] = new int[6]; scores[1] = new int[3]; scores[2] = new int[2]; scores.length scores[rowNumberHere].length scores.size() scores[rowNumberHere].size()

scores[rowNumberHere].length


Set pelajaran terkait

Into American Gov. Midterm study

View Set

To Kill a Mockingbird chapter 10-17

View Set

Civil Law and Procedure (Tort to Fraud)

View Set

Chapter 13/1: Medical Expense Insurance

View Set