1. | To what type must the conditional expression of a selection or iteration statement evaluate? |
|
2. | What’s the purpose of a selection statement? |
|
3. | What’s the purpose of an iteration statement? |
|
4. | What four types can be used for switch statement values? |
|
5. | What’s the primary difference between a while statement and a do/while statement? |
|
6. | Explain why, in some programming situations, you would choose to use a do/while statement vs. a while statement. |
|
7. | When would you use a switch statement vs. chained if/else statements? |
|
8. | For what purpose is the break statement used in switch statements? |
|
9. | What’s the effect of using an unlabeled break statement in an iteration statement? |
|
10. | What’s the effect of using a labeled break statement in an iteration statement? |
|
11. | What’s the effect of using an unlabeled continue statement in an iteration statement? |
|
12. | What’s the effect of using a labeled continue statement in an iteration statement? |
|
Answers
1. | - boolean |
2. | - alters the flow of program execution based on the evaluation of a boolean expression |
3. | - iteration statements repeat the statements located in their body based on the results of an expression |
4. | - int, char, byte, short |
5. | - a do/while statement will execute its body code at least once |
6. | - when you need to execute the statements contained in the iteration statement body at least once |
7. | - when your evaluation criteria is based on an int, short, byte, or char |
8. | - to prevent case statement fall-through |
9. | - it exits the inner-most enclosing iteration statement |
10. | - it will exit the named iteration statement |
11. | - it will stop execution and start at the beginning of its enclosing iteration statement |
12. | - it will stop execution and begin execution of the named iteration statement |