Java Chapter 7
When an array is created, its elements are assigned to what for boolean data types?
false
What is the array initializer?
A shorthand notation that combines declaring an array, creating an array, and initializing an array in one statement
What must an index be?
An integer or integer expression
What happens if you attempt to reference elements beyond the bounds of an array?
An out-of-bounds error will occur
If an array is sorted, what should you use to find an element in the array?
Binary search
What do you have to do to an array before you can assign elements?
Create the array
What does selection sort do?
It finds the smallest number in the list and swaps it with the first element. Then it 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
When an array is created, what happens to its elements for the numeric primitive data types?
Its elements are assigned the default value of 0
Is an array variable a primitive data type?
No
What happens to the size of an array after it is created?
The size becomes permanent
How do you declare a variable as an array type?
Use the syntax elemetType[] arrayRefVar or elementType arrayRefVar[]
What is the index off-by-one error?
When programmers often mistakingly reference the first element in an array with index 1 instead of index 0
What happens when you pass an array argument to a method?
You are actually passing the reference of the array aka the called method can modify the elements in the caller's original array
When an array is created, its elements are assigned to what for char data types?
\u0000
How do you create an array?
new elementType[arraySize]
After an array is created, its size becomes permanent and can be obtained using what?
arrayRefVar.length
How do you represent each element in an array?
arrayRefVar[index]
What is the reference for the first element in an array?
index 0