Chapter 5 Flashcards

1
Q

What is the 4 step process in constructing a while loop?

A

1) Identify the actions that must be repeated in the loop
2) Identify the boolean expression that must be true in order for the while statement to run
3) Assemble the while loop
4) Add additional actions before or after the loop to complete the solution.

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

Define 5 characteristics of a temporary variable

A

1) Also called local variables
2) Occur inside a method
3) Store a value until the end of the method
4) Have a value type
5) Must be given an initial value

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

Define scope

A

The region of the program in which a variable may be used

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

Define 4 types of legal expressions

A

1) Literal values
2) Variables
3) Methods
4) Operators whose operands are legal expressions

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

What loop do you use if a parameter refers to the number of times the loop will execute

A

a count-down loop or a for loop

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

What loop do you use if the number of times the loop will execute is known before the loop is entered?

A

A for loop

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

What loop do you use if the loop might execute zero times?

A

A while loop

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

What loop do you use if the loop has a single test that is relatively simple that appears at the top of the loop?

A

A while loop

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

What loop do you use if the loop always executes at least once?

A

A do-While loop

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

What loop do you use if the loop executes an extra half time?

A

Use a while-true loop

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

What loop do you use if the loop had multiple exit tests?

A

A while-true loop

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

What is short-circuit evaluation?

A

if the first evaluation is false in the series of Boolean expressions, it will skip the second expression

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