Java Array quiz

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

What would 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.

What would be the result after the following code is executed? 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]; }

This code would cause the program to crash.

What will be the results after the following code is executed? 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

The sequential search algorithm ________.

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

If any int array, a, is passed as a parameter to a method, which of the following would adequately define the parameter list for the method header?

(int[] a)

Given the following two-dimensional array declaration, which statement is true? int[][] numbers = new int[6][9];

The numbers array has 6 rows and 9 columns.

In memory, an array of String objects ________.

consists of an array of references to String objects

If a and b are both int arrays, then a = b; will

create an alias

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

Which of the following is a correct method header for receiving a two-dimensional array as an argument?

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

When an array is passed to a method ________.

- the method has direct access to the original array - a reference to the array is passed -it is passed just as any other object would be passed

Subscripting always starts with ________.

0

Given the following code and assuming list is an int array that stores positive int values only. Which of the following tasks is accomplished by this code? int foo = 0; for (int j =0 ; j < list.length; j++) if (list[j] > foo) foo = list[j];

It stores the largest value of list in foo

What will be the result after the following code is executed? final int ARRAY_SIZE = 5; float[] x = float[ARRAY_SIZE]; for (i = 1; i <= ARRAY_SIZE; i++) { x[i] = 10.0; }

The code contains a syntax error and will not compile.

A search algorithm ________.

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

If numbers is a two-dimensional array, which of the following would give the number of columns in row r?

numbers[r].length

In Java, arrays are

objects

The ________ indicates the number of elements the array can hold.

array's size declarator

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

initialization list

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

final

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

subscript


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

Jacquie-Baking Chapter 17 Tortes

View Set

MIT 103 Chapter 12 - The Endocrine System

View Set

7th math - Area of Composite Figures

View Set

Quiz 1 Basic Sciences III Class 22'

View Set

AU 60 - Assignment 5 - Understanding Financial Statements

View Set