Control Statements Flashcards

1
Q

___ is an informal language that helps you develop algorithms without having to worry about the strict details of Java language syntax.

A

a) Pseudocode

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

The process of executing the statements in a program one after the other in the order in which they’re written is called ___ .

A

b) sequential execution.

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

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.

A

c) sentinel, signal, flag or dummy

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

Java is a(n) ___ language; it requires all variables to have a type.

A

d) strongly typed

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

___ enable programs to perform statements repeatedly as long as a condition re- mains true.

A

e) Repetition statements

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

a) The if statement is a double-selection statement.

A

a) False. It is a single-selection statement because it selects or ignores a single action

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

b) Java provides the ternary operator(?:), which can be used in place of a do…while statement.

A

b) False. Java’s ternary operator (?:) cannot be used in place of an do…while statement.

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

c) A nested control statement appears in the body of another control statement.

A

c) True.

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

d) Specifying the order in which statements execute in a program is called program control.

A

d) True.

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

e) A nonfatal logic error causes a program to fail and terminate prematurely.

A

e) False. A nonfatal logic error allows a program to continue executing but causes it to produce in- correct results.

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

Typically, ___ statements are used for counter-controlled repetition and ___ statements for sentinel-controlled repetition.

A

a) for, while

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

The do…while statement tests the loop-continuation condition ___ executing the loop’s body; therefore, the body always executes at least once.

A

b) after

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

The ___ statement selects among multiple actions based on the possible values of an integer variable or expression.

A

c) switch

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

The ___ operator can be used to ensure that two conditions are both true before choosing a certain path of execution.

A

d) continue

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

If the loop-continuation condition in a for header is initially ___ , the program does not execute the for statement’s body.

A

e) && (conditional AND)

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

a) The default case is required in the switch selection statement.

A

a) False. The default case is optional. If no default action is needed, then there’s no need for a default case

17
Q

b) The break statement is required in the last case of a switch selection statement.

A

b) False. The break statement is used to exit the switch statement. The break statement is not required for the last case in a switch statement

18
Q

c) The expression( ( x > y ) && ( a < b ) ) is true if either x > y is true or a < b is true.

A

c) False. Both of the relational expressions must be true for the entire expression to be true when using the && operator

19
Q

d) An expression containing the || operator is true if either or both of its operands are true.

A

d) True

20
Q

e) Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.

A

e) True