Control Structures (H6) Flashcards

(24 cards)

1
Q

used to control the execution flow of the program.

A

Control Statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Java Types of Control Statements

A
  1. Selection
  2. Repetition
  3. Branching
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Selection statements are decision-making statements that include if, if-else, and switch statements.

A

Selection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The _ decision construct is followed by a logical expression wherein data is compared, and a decision is
made depending on the comparison result.

A

if statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

It is an extension of the if statement that provides an alternative action when the if statement results in a
false outcome.

A

if-else statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

the set of statements between two curly braces ({, }).

A

block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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.

A

switch statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The ______ must always be the last option in the switch construct if used

A

default label

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

are looping statements that include while, do-while, and for statements.

A

Repetition statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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.

A

while loop statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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 _____.

A

loop control variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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.

A

do-while loop statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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.

A

unknown

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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.

A

for loop statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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.

A

Initialization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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.

17
Q

this expression is always executed when the control returns to the beginning of the loop.

A

Increment/Decrement

18
Q

These statements transfer control to another part of the program.

19
Q

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.

A

break statement

20
Q

which breaks the innermost loop or switch statement.

21
Q

which breaks the outermost loop in the series of nested loops. A nested loop is a loop that exists within another loop.

22
Q

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.

A

continue statement

23
Q

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.

A

return statement

24
Q

return statement syntax

A
  • return values;
  • return; – returns nothing, so this can be used when a method is declared with a void return type.
  • return expression; – returns the value evaluated from the expression.