Unit 3 Exam Flashcards

(15 cards)

1
Q

Min number of iterations for do while

A

1

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

Min number of iterations for while

A

0, because boolean expression is first so if it is false loop never runs

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

What happens with continue inside a for

A

Skips the code below it and increments

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

Min number of iterations for for

A

1

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

What does empty boolean expression in for do

A

Always evaluates to true

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

for(;;){
SOP(“hello”)
}

A

Infinite loop

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

Reference of array

A

Address where data is stored in RAM

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

Index of array

A

Integer between 0 and array size - 1

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

int [] nums = new int [10]

A

int = data type
[ ] = array
nums = array name
new = reserves enough RAM to store size values
10 = size

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

nums [1] = 3;
nums [3] = 20;
nums [7] = nums [nums [1]] - 8;

A

nums [7] is 12

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

.length

A

Constant that is equal to the size of the array
Used for iterating through an array

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

Initializing arrays

A

int [] nums = new int [50]; // all values set to 0
String [] days = {“Mon”, “Tues”, “Wed”};

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

Passing arrays to methods

A

When an array is passed using a method, the reference is passed by value
This means that when an array that is passed through a method is modified, it is changing the original

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

2d arrays

A

Each element in the array is also an array
Syntax int [ ] [ ] arr

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

Iterating through a 2d array

A

for(int row = 0; row < a.length; row++){
for(int col = 0; col < a[row].length; col++){
System.out.print(a[row][col] + “ “);
} // for
System.out.println(“ “);
} // for

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