Ch. 5 Control Statements Part 2 Flashcards

1
Q

Typically, _______ statements

are used for counter-controlled repetition and ______

statements for sentinel-controlled repetition.

A

for

while

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

The “do…while” statement test the loop-continuation condition ______ executing the loop’s body; therefore teh body always executes at least once.

A

after

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

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

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

The ______ statement, when executed in a repetition statement, skips teh remaining statements in the loop body and proceeds with the next iteration of the loop.

A

continue statement

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

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

A

&&

(Conditional AND)

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

If the loop-continuation condition in a for header is initially ______, the program does not execute the for statements body.

A

false

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

Methods that perfrom common tasks and do not require objects are called ______ methods.

A

static methods

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

The default case is required in the switch selection statement.

A

False

the default case is optional

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

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

A

false

the break statement is used to exit the switch statement

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

The expression ( ( x > y) && ( a < b) )

is true if either x > y is true or a < b is ture

A

false

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

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

The comma (,) formatting flag in a format specifier

(eg %,20.2f) indicates that a value should be output with a thousands seperator.

A

True

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

An expression containing “ll” operator is true if either or both of its operands are true

A

true

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

To test for a range of values in a switch statement, use a hyphen (-) between the start and end values of the range in a case lablel

A

False

The switch statement does not provide a mechanism for testing ranges of values, so every value that must be tested should be listed in a seperate case label

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

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

A

True

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