COP 2800 Chapter 7

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

This ArrayList class method deletes an item from an ArrayList.

remove

You can use this ArrayList class method to replace an item at a specific location in an ArrayList.

set

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 would be the results after the following code was executed? int[] x = {23, 55, 83, 19}; int[] y = {46, 78, 12, 24}; x = y; y = x;

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

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 will be the result of executing the following code? int[] x = {0, 1, 2, 3, 4, 5};

An array of 6 values ranging from 0 through 5 and referenced by the variable x will be created.

By default, Java initializes array elements with what value?

0

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 would be the results of the following code? final int SIZE = 25; int[] array1 = new int[SIZE]; // Code that will put values in array1 int value = 0; for (int a = 0; a < array1.length; a++) { value += array1[a]; }

Correct Value contains the sum of all the values in array1.

In order to do a binary search on an array:

Correct the array must first be sorted in ascending order

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 - 9 (all of these)

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?

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

Which of the following for loops is valid, given the following declaration? String[] names = {"abc", "def", "ghi", "jkl"};

for (int i = 0; i < names.length; i++) System.out.println(names[i].length());

In Java, you do not use the new operator when you use a(n):

initialization list

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

A sorting algorithm is a technique for scanning through an array and rearranging its contents in some specific order.

True

Once an array is created, its size cannot be changed.

True

A search algorithm:

is a way 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[]


संबंधित स्टडी सेट्स

Chapter 9 Consultation and Documentation

View Set

CCTP Level 1-Basic Care and Handling Section 3-4: Vaccines and Preventatives Exam

View Set

HESI PN Multidisciplinary Practice Quiz

View Set

Chapter 14: Physiological and Behavioral Adaptations of the Newborn

View Set

Computer Concepts Exam Chapters 3-4

View Set

Unit 2 Progress Check: MCQ - AP Psychology

View Set

SUCCESS! In Clinical Laboratory Science Bacteriology - Antimicrobial Agents and Antimicrobial Susceptibility Testing

View Set