Loops Flashcards

1
Q

The three main types of loops in Java.

A

1) for loop
2) while loop
3) do while loop

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

A loop situation where we don’t know how many iterations a loop will do in advance.

A

Indeterminate

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

Which type of loop is best for indeterminate?

A

while or do-while

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

Which type of loop is best for determinate?

A

for-loop or counter-controlled-while

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

LCC

A

Loop Continuation Condition

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

How do you get an infinite loop?

A

The loop continuation condition never becomes false

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

The use of a specific input by the user to end the loop, like zero.

A

Sentinel Value

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

Which loop is guaranteed to run at least once?

A

do-while

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

Which type of loop is a for-loop? (det/indet)

A

Determinate

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

What is it called when you manually adjust a for loop’s counter?

A

Heretic’s Code

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

What happens if you put a semicolon at the end of a for-loop header?

A

Separates the body from the header, making the counter go and then running the body ONCE.

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

Which keyword is used to exit a loop in the middle of an iteration?

A

break

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

Which keyword is used to stop the current iteration of the loop and go back to LCC?

A

continue

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

What special loop syntax can be used for traversing data structures?

A

for:each

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

What is the syntax of a for:each loop?

A

for(datatype temp : collection_name)

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