Answers to Self-Review Exercises (Sections C.14–C.20)
-
for
,while
.after.
switch
.&&
(conditional AND).false
.
-
False. The
default
case is optional. If no default action is needed, then there’s no need for adefault
case.False. The
break
statement is used to exit theswitch
statement. Thebreak
statement is not required for the last case in aswitch
statement.False. Both of the relational expressions must be true for the entire expression to be true when using the
&&
operator.True.
True.
-
-
sum = 0; for ( count = 1; count <= 99; count += 2 ) sum += count;
-
double result = Math.pow( 2.5, 3 );
-
i = 1; while ( i <= 20 ) { System.out.print( i ); if ( i % 5 == 0 ) System.out.println(); else System.out.print( '\t' ); ++i; } ...
-
Get Android How to Program, 3/e 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.