006 - Control Flow Statements Flashcards
__________ break up the flow of execution by employing decision making, looping, and branching, enabling your program to conditionally execute particular blocks of code.
Control flow statements
__________ tells your program to execute a certain section of code only if a particular test evaluates to true.
The if-then statement
In an if-then statement, __________are optional, provided that the “then” clause contains only one statement:
the opening and closing braces
__________ provides a secondary path of execution when an “if” clause evaluates to false.
The if-then-else statement
__________ can have a number of possible execution paths.
the switch statement
A switch works with the __________ primitive data types
byte, short, char, and int
A switch works with __________ types, the _________ class, and a few special classes that wrap certain primitive types: __________.
enumerated
String
Character, Byte, Short, and Integer
The body of a switch statement is known as _________.
a switch block
A statement in the switch block can be labeled with _________.
one or more case or default labels
The switch statement evaluates its expression, then executes all statements that __________.
follow the matching case label
Deciding whether to use if-then-else statements or a switch statement is based on __________ and __________.
readability
the expression that the statement is testing
An if-then-else statement can test expressions based on __________ or __________, whereas a switch statement tests expressions based __________, __________, or __________.
ranges of values or conditions
only on a single integer,
enumerated value or
String object.
Each __________ terminates the enclosing switch statement.
break statement
The break statements are necessary because without them, __________.
statements in switch blocks fall through
All statements after the matching case label are executed in sequence, regardless of the expression of subsequent case labels, until a __________.
break statement is encountered
Technically, a break in __________ is not required because flow falls out of the switch statement.
the final case section
The __________handles all values that are not explicitly handled by one of the case sections.
default section
In Java SE 7 and later, you can use __________ in the switch statement’s expression.
a String object
The __________continually executes a block of statements while a part
while statement
The while statement evaluates __________, which must return __________.
An expression
a boolean value