Chapter 8


Chaper 7

1. 

To what type must the conditional expression of a selection or iteration statement evaluate?

image from book

2. 

What’s the purpose of a selection statement?

 - alters the flow of program execution based on the evaluation of a boolean expression

3. 

What’s the purpose of an iteration statement?

image from book

4. 

What four types can be used for switch statement values?

 - int, char, byte, short

5. 

What’s the primary difference between a while statement and a do/while statement?

 - a do/while statement will execute its body code at least once

6. 

Explain why, in some programming situations, you would choose to use a do/while statement vs. a while statement.

 - when you need to execute the statements contained in the iteration statement body at least once

7. 

When would you use a switch statement vs. chained if/else statements?

 - when your evaluation criteria is based on an int, short, byte, or char

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?

 - it exits the inner-most enclosing iteration statement

10. 

What’s the effect of using a labeled break statement in an iteration statement?

 - it will exit the named iteration statement

11. 

What’s the effect of using an unlabeled continue statement in an iteration statement?

 - it will stop execution and start at the beginning of its enclosing iteration statement

12. 

What’s the effect of using a labeled continue statement in an iteration statement?

 - it will stop execution and begin execution of the named 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




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net