Answers to Self-Review Exercises
a) for
, while
.
b) after.
c) switch
.
d) continue
.
e) &&
(conditional AND).
f) false
.
g) static
.
a) False. The default
case is optional. If no default action is needed, then there’s no need for a default
case.
b) False. The break
statement is used to exit the switch
statement. The break
statement is not required for the last case in a switch
statement.
c) False. Both of the relational expressions must be true for the entire expression to be true when using the &&
operator.
d) True.
e) True.
f) False. The switch
statement does not provide a mechanism for testing ranges of values, so every value that must be tested should be listed in a separate case
label.
g) True.
a)
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.