Chapter 8: Arrays

Ace your homework & exams now with Quizwiz!

When any primitive type is passed to a method, the ____ is passed.

value

When any primitive type variable is passed to a method, the _____ is passed.

value

You use a ____ following the closing brace of an array initialization list.

;

When you declare int[]someNums = new int[10];, each element of someNums has a value of ____.

0

Parallel arrays do not necessarily have the same number of elements.

False

Since an array name is a reference, you are able to use the = operator for assigning and the == operator for comparisons.

False

When using parallel arrays, if one array has many possible matches, it is most efficient to place the less common items first so that they are matched right away.

False

When an application contains an array and you want to use every element of the array in some task, it is common to perform loops that vary the loop control variable from 0 to one less than the size of the array.

True

When array elements are passed by value, a copy of the value is made and used within the receiving method.

True

When returning an array reference, square brackets are included with the return type in the method header.

True

When you declare or access an array, you can use any expression to represent the size, as long as the expression is _____.

an integer

In which of the following statements is the value of myVals null?

int [ ] myVals;

When you create an array variable, memory space is automatically reserved.

False

When you want to determine whether a variable holds one of many valid values, one option is to use a do...while loop to compare the variable to a series of valid values.

False

To initialize an array, you use an initialization list of values separated by commas and enclosed within curly braces.

True

When a method returns an array reference, you include ____ with the return type in the method header.

[ ]

A(n) ____ is a variable that holds a value as an indicator of whether some condition has been met.

flag

Which of the following statements correctly initializes an array with an initialization list?

int[ ] nums = {2, 4, 8};

When you declare an array name, no computer memory address is assigned to it. Instead, the array variable name has the special value ____, or Unicode value '\u0000'.

null

A ____ array is one with the same number of elements as another, and for which the values in corresponding elements are related.

parallel

Individual array elements are ____ by value when a copy of the value is made and used within the receiving method.

passed

Providing values for all the elements in an array is called ____ the array.

populating

When any ____ type (boolean, char, byte, short, int, long, float, or double) is passed to a method, the value is passed.

primitive

An instance variable or object field is also called a(n) ____ of the object.

property

When you perform a ____, you compare a value to the endpoints of numerical ranges to find the category in which a value belongs.

range match

It is a good programming practice to ensure that a subscript to an array does not fall below zero, causing a(n) ____.

runtime error

Comparing a variable to a list of values in an array is a process called ____ an array.

searching

After you create an array variable, you still need to ____ memory space.

reserve

Languages such as Visual Basic, BASIC, and COBOL use ____ to refer to individual array elements.

( )

You can declare an array variable by placing curly brackets after the array name.

False

Which of the following println statements will display the last myScores element in an array of 10?

System.out.println(vals[9]);

Which of the following statements correctly declares and creates an array to hold five double scores values?

double[] scores = new double[5]

A(n) ____ loop allows you to cycle through an array without specifying the starting and ending points for the loop control variable.

enhanced for

In Java, boolean array elements automatically are assigned the value ____.

false

The length ____ contains the number of elements in the array.

field

When you declare or access an array, you can use any expression to represent the size, as long as the expression is a(n) ____.

integer

If a class has only a default constructor, you must call the constructor using the keyword ____ for each declared array element.

new

When you create an array of objects, each reference is assigned the value ____.

null

When you initialize parallel arrays, it is convenient to use ____ so that the values that correspond to each other visually align on the screen or printed page.

spacing

A(n) ____ is an integer contained within square brackets that indicates one of an array's variables.

subscript


Related study sets

Toxicity 5: Factors Affecting Toxicity

View Set

ATI med surg ch 35: peripheral vascular diseases questions

View Set

Chapter 17: European Power and Expansion

View Set

BIO 141: Chapter 5 (The Structure and Function of Large Biological Molecules) Review

View Set

Chapter 1 - Types of Value and Valuation

View Set