Week 11 Part 3 Flashcards

1
Q

o Arrays of [char, byte, short, int, long, float, double] have every element initialized to _ by default, array elements of Boolean type will be _____, and an array of reference type will have every element set to ____

A

 0, false, null

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

o What will every single element value be in this freshly initialized array?
private int[] numbers = new int[42]

A

All elements are 0

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

o What are yetMoreNumbers element values?
o Int[] otherNumbers = new int [42]
double[] yetMoreNumbers = null
yetMoreNumbers = new double[42]

A

All are 0

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

o Why would you ever defer instantiation of an array (sometimes just to a separate line)?

A

You do not yet know how large to make the array

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

o By using an Array ___________ ____when creating an Array we can specify what each element contains

A

Initializer list

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

o char[] letterGrades = { ‘A’, ‘B’, ‘C’, ‘D’ ‘F’ }; What will the size of this array be? What will be the index of the letter A?

A

Size 5, A will be 0

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

o T/F – You can place the Array reference variable declaration and the Initializer list on different lines

A

False

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

o Initializer lists are best suited to short arrays, _____ are better suited for larger arrays

A

Loops

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

o If you specify an index below zero or one that exceeds the maximum length

A

ArrayIndexOutOfBoundsException

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

o ___ loops are best for arrays

A

For

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

o Identify this
For (int grade : letterGrades) {
System.out.println( grade );

A

Enhanced for loop

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

o This loop figures out where to start and where to stop

A

Enhanced for loop

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

o Limitation of the advanced for loop

A

It’s read-only, no exceptions

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