Chapter 8 - Terminology Flashcards

1
Q

An ____ is a sequence of variables of the same data type. The data type can be any Java primitive data type, such as int, float, double, byte, short, long, boolean, or char, or it can be a class.

A

array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Each ____ in the array is accessed using the array name and an index, which refers to the ____’s position in the array.

A

element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Arrays are implemented as _____.

A

objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Creating an array consists of _____.

A

declaring an object reference for the array and instantiating the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The size of the array is given when the array is _____.

A

instantiated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In arrays of ____ types, each element of the array contains a value of that type.

A

primitive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In arrays of ____, each element is an object reference.

A

objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When an array is instantiated, the elements are given initial values automatically, depending on the data type. Numeric types are set to ____; boolean types are set to ____; char types are set to the ____; and object references are set to ____.

A

Numeric = 0
Boolean = false
Char = unicode null character
object references = null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Instantiating an array of object references involves two steps:

A

instantiating the array and instantiating the objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Arrays can be instantiated when they are declared by assigning initial values:

A

in a comma-separated list within curly braces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The number of values in the initialization list determines:

A

the number of elements in the array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Array elements are accessed using the:

A

array name and an index. (ie. a[i])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The first element’s index is __ and the last element’s index is ___.

A

0 and array.length-1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Arrays have an integer instance variable, ____, which holds the number of elements in the array.

A

length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Attempting to access an element of an array using an index less than 0 or greater than arrayName.length – 1 will generate an:

A

ArrayIndexOutOfBoundsException at run time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

True or False? Aggregate array operations, such as printing and copying arrays, are supported for arrays.

A

False, they are not supported and you would have to use a loop to process each array element individually.

17
Q

To change the size of an array:

A
  1. instantiate an array of the desired size with a temporary name,
  2. copy the appropriate elements from the original array to the new array,
  3. assign the new array reference to the original array.
  4. Assign null to the temporary array name.
18
Q

Arrays can be passed as ____ to methods and can also be the ___ type of methods.

A

arguments and return type

19
Q

True or False? When an array is an instance variable of a class, the constructor should instantiate a new array and copy the elements of the parameter array into the new array.

A

True

20
Q

A _________ determines whether a particular value, the search key, is in an array by comparing the search key to each element in the array.

A

Sequential Search

21
Q

A ______ arranges elements in the array in order by value by reducing the array into successively smaller subarrays and placing the largest element in each subarray into the last position of the subarray.

A

Selection Sort

22
Q

An _______ arranges elements of an array much like a card player arranges cards in sorted order in his or her hand. The elements are inserted one at a time in ascending order into the left side of the array.

A

Insertion Sort

23
Q

To sort an array of objects, we can use the _____ to compare objects’ values.

A

class method provided

24
Q

A sorted array can be searched more efficiently using a ______, which successively reduces the number of elements to search by half.

A

Binary Search

25
Q

Arrays of _____ can be used as an ordered group of counters.

A

integers

26
Q

Methods can accept a variable number of parameters using the _____

A

varargs … syntax