used to control the execution flow of the program.
Control Statements
Java Types of Control Statements
Selection statements are decision-making statements that include if, if-else, and switch statements.
Selection
The _ decision construct is followed by a logical expression wherein data is compared, and a decision is
made depending on the comparison result.
if statement
It is an extension of the if statement that provides an alternative action when the if statement results in a
false outcome.
if-else statement
the set of statements between two curly braces ({, }).
block
It is considered an easier implementation of the if-else statement. It is used whenever there are multiple values possible for a variable. This statement successfully lists the value of a variable or an expression against a list of byte, short, char, or int primitive data types only. The statements linked with that case constant are executed when a match is found.
switch statement
The ______ must always be the last option in the switch construct if used
default label
are looping statements that include while, do-while, and for statements.
Repetition statements
It is a looping construct that continues until the evaluating condition becomes false. The evaluating condition must be a logical expression and must return a true or a false value. The variable checked in the Boolean expression is called the loop control variable.
while loop statement
It is a looping construct that continues until the evaluating condition becomes false. The evaluating condition must be a logical expression and must return a true or a false value. The variable checked in the Boolean expression is called the _____.
loop control variable
Another looping statement that lists the conditions after the statements to be executed. This statement can be considered a post-test loop statement. First, the do block statement is executed, and then, the condition given in the while statement is checked.
do-while loop statement
The while and do-while loops are used whenever the number of repetitions or iterations is _____. Iterations refer to the number of times the loop body is executed.
unknown
Compared to while and do-while statements, the _____ is used when iterations are known in advance. This looping statement can be used when determining the square of each of the first ten numbers.
for loop statement
gives the loop variable an initial value. This expression is executed only once when the control is passed to the loop for the first time.
Initialization
executes the condition each time. The control passes to the start of the loop. The loop’s body is executed only after the condition has been checked. If the condition is true, the loop is executed. Otherwise, the control is passed to the following statement.
Test
this expression is always executed when the control returns to the beginning of the loop.
Increment/Decrement
These statements transfer control to another part of the program.
Branching
It is a branching statement that can be labeled or unlabeled. This statement is used for breaking loop
executions such as of while, do-while, and for. It also terminates the switch statements.
break statement
which breaks the innermost loop or switch statement.
break
which breaks the outermost loop in the series of nested loops. A nested loop is a loop that exists within another loop.
break label;
It is used in looping statements such as while, do-while, and for to skip the current iteration of the loop
and resume to the next iteration.
continue statement
It transfers the control to the caller of the method. It is used to return a value to the caller method and
terminates the execution of the method. It has two forms: one that returns a value and the other that
cannot return a value. The returned value type must match the return types of the caller method.
return statement
return statement syntax