Loop Constructs Flashcards
What does a break statement with no label do?
It tries to pass control to the innermost enclosing (switch, while, do, or for statement).
If there is no statement it will not compile.
What does a break statement with a label do?
It passes control to the enclosing labeled statement with the same identifier.
What does a continue statement with no label do?
It tries to pass control to the innermost enclosing statement and begin a new iteration.
What does a continue statement with a label do?
It transfers control to the enclosing labelled target statement, ending the current iteration and beginning a new one.
What does the break statement do in a while loop?
It breaks out of the loop completely.
Can the enhanced for loop iterate over a Map?
No.
It only iterates over an array or a Collection.
How is not having an explicit condition check advantageous in the enhanced for loop?
It makes it less likely to write code causing an infinite loop.
Can you find the number of the current iteration when using the enhanced for loop?
No.
Where can labels be applied to?
They can be applied to any code block or block level statement.