Loop Constructs Flashcards

1
Q

What does a break statement with no label do?

A

It tries to pass control to the innermost enclosing (switch, while, do, or for statement).

If there is no statement it will not compile.

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

What does a break statement with a label do?

A

It passes control to the enclosing labeled statement with the same identifier.

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

What does a continue statement with no label do?

A

It tries to pass control to the innermost enclosing statement and begin a new iteration.

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

What does a continue statement with a label do?

A

It transfers control to the enclosing labelled target statement, ending the current iteration and beginning a new one.

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

What does the break statement do in a while loop?

A

It breaks out of the loop completely.

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

Can the enhanced for loop iterate over a Map?

A

No.

It only iterates over an array or a Collection.

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

How is not having an explicit condition check advantageous in the enhanced for loop?

A

It makes it less likely to write code causing an infinite loop.

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

Can you find the number of the current iteration when using the enhanced for loop?

A

No.

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

Where can labels be applied to?

A

They can be applied to any code block or block level statement.

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