Control Statements Flashcards
___ is an informal language that helps you develop algorithms without having to worry about the strict details of Java language syntax.
a) Pseudocode
The process of executing the statements in a program one after the other in the order in which they’re written is called ___ .
b) sequential execution.
When it’s not known in advance how many times a set of statements will be repeated, a(n) ___ value can be used to terminate the repetition.
c) sentinel, signal, flag or dummy
Java is a(n) ___ language; it requires all variables to have a type.
d) strongly typed
___ enable programs to perform statements repeatedly as long as a condition re- mains true.
e) Repetition statements
a) The if statement is a double-selection statement.
a) False. It is a single-selection statement because it selects or ignores a single action
b) Java provides the ternary operator(?:), which can be used in place of a do…while statement.
b) False. Java’s ternary operator (?:) cannot be used in place of an do…while statement.
c) A nested control statement appears in the body of another control statement.
c) True.
d) Specifying the order in which statements execute in a program is called program control.
d) True.
e) A nonfatal logic error causes a program to fail and terminate prematurely.
e) False. A nonfatal logic error allows a program to continue executing but causes it to produce in- correct results.
Typically, ___ statements are used for counter-controlled repetition and ___ statements for sentinel-controlled repetition.
a) for, while
The do…while statement tests the loop-continuation condition ___ executing the loop’s body; therefore, the body always executes at least once.
b) after
The ___ statement selects among multiple actions based on the possible values of an integer variable or expression.
c) switch
The ___ operator can be used to ensure that two conditions are both true before choosing a certain path of execution.
d) continue
If the loop-continuation condition in a for header is initially ___ , the program does not execute the for statement’s body.
e) && (conditional AND)