CMPS 161 Chapter 7 Single-Dimmensional Arrays: Chapter Summary

Ace your homework & exams now with Quizwiz!

You cannot assign elements to an array unless it has already been created. You can create an array by using the _____ operator with the following syntax: _____ _____.

new, new elementType[arraySize]

Programmers often mistakenly reference the first element in an array with index _, but it should be _. This is called the index _____-_____-_____ error.

off-by-one

Unlike declarations for primitive data type variables, the declaration of an array variable does not allocate any space in memory for the array. An array variable is not a _____ data type variable. An array variable contains a reference to an array.

primitive

When you pass an array argument to a method, you are actually passing the _____ of the array; that is, the called method can modify the elements in the caller's original array.

reference

When an array is created, its elements are assigned the default value of __ for the numeric primitive data types, _____ for char types, and _____ for boolean types.

0, \u0000, false

_____ _____ finds the smallest number in the list and swaps it with the first element. It then finds the smallest number remaining and swaps it with the first element in the remaining list, and so on, until only a single number remains.

Selection sort

Java has a shorthand notation, known as the _____ _____, which combines declaring an array, creating and array, and initializing an array in one statement, using the syntax _____ _____ __ _____.

array initializer, elementType[] arrayRefVar = {value0, value1, ..., valuek}

A variable is declared as an _____ _____ using the syntax _____ or _____. The style _____ is preferred, although _____ is legal.

array type, elementType[] arrayRefVar, elementType arrayRefVar[], elementType[] arrayRefVar, elementType arrayRefVar[]

After an array is created, its size becomes permanent and can be obtained using _____. Since the index of an array always begins with _____, the last index is always _____. An out-of-bounds error will occur if you attempt to reference elements beyond the bounds of an array.

arrayRefVar.length, 0, arrayRefVar.length - 1

Each element in the array is represented using the syntax _____. An _____ must be an integer or an integer expression.

arrayRefVar[index], index

If an array is sorted, _____ _____ is more efficient than _____ _____ for finding an element in the array.

binary search, linear search


Related study sets

Praxis Core 5722 - Writing Concepts

View Set

Chapter 15 Evolve Questions (Anxiety and Obsessive-Compulsive Disorders)

View Set

Characteristics of Blood (Human A&P)

View Set

Mental health prepu - Chp 19-Anger

View Set

4510: Concept Synthesis, Exam 1 - Oxygenation, Perfusion, Elimination, Fluid and Electrolyte, Infection

View Set

3- Risk Management & Internal Controls

View Set

5.2 APIPA and Alternate Addressing

View Set