Java Chapter 6
Loop
A ____ is a structure that allows repeated execution of a block of statements.
Counter Controlled
A for loop provides a convenient way to create a(n) ____ loop.
Incrementing
A loop controlled by the user is a type of ____ loop.
infinite
A loop that never ends is a(n) _____ loop.
Infinite
A loop that never ends is called a(n) ____ loop.
True
A statement that will alter the value of the loop control variable is included in the body of a loop.
loop
A structure that allows repeated execution of a block of statements is a _____.
sentinel
A value that stops a loop is a _____.
For
A(n) ____ loop is a special loop that is used when a definite number of loop iterations is required.
Do-nothing
A(n) ____ loop is one that performs no actions other than looping.
priming read
A(n) _____ is the first input statement prior to a loop that will execute subsequent input statements for the same variable.
event-controlled
A(n) _____ loop is an indefinite loop in which the number of executions is determined by user actions.
True
Altering a variable within both a for statement and within the block it controls can produce errors that are difficult to find.
Event controlled
An indefinite loop is a(n) ____ loop.
Loop fusion
As long as methods do not depend on one another, ____ is a technique that can improve loop performance by combining two loops into one.
Priming read
Before entering a loop, the first input statement, or ____, is retrieved.
False
Programmers rarely use indefinite loops when validating input data.
False
Shortcut operators are a programmer's only choice when incrementing or accumulating a variable's value.
Do...while
The ____ loop checks the value of the loop control variable at the bottom of the loop after one repetition has occurred.
do...while
The loop that performs its conditional check at the bottom of the loop is a _____ loop.
binary
The modulus operator ( % ) is a _____ operator.
Nested
The order of the conditional expressions in the following is most important within a(n) ____ loop. while(requestedNum > LIMIT || requestedNum < 0)
unary
The prefix ++ is a _____ operator.
Accumulating
The process of repeatedly increasing a value by some amount is known as ____.
False
The statements that make up a loop body will continue to execute as long as the expression value remains false.
variable
To construct a loop that works correctly, you should initialize a loop control _____.
The loop control variable is reset to its starting value during each iteration of the loop.
To prevent a while loop from executing infinitely, which of the following actions must not occur?
While
Use a(n) ____ loop to execute a body of statements continually as long as the Boolean expression that controls entry into the loop continues to be true.
for(a=1, b=2)
When creating a for loop, which statement will correctly initialize more than one variable?
prefix increment
When incrementing the loop control variable in a for statement, using the _____ operator produces a faster loop.
inner, outer
When loops are nested, each pair contains a(n) _____ loop and a(n) _____ loop.
False
When nesting loops, the variable in the outer loop changes more frequently.
Prefix increment operator
When you want to increase a variable's value by exactly 1, use the ____.
loopCount = 1; while(loopCount < 3); { System.out.println("Hello");
Which is an infinite loop?
++score = score + 1
Which of the following is NOT a valid method to increase a variable named score by 1?
Making a comparison to -1.
Which of the following will not help improve loop performance?
Comma
You can initialize more than one variable in a for loop by placing a(n) ____ between the separate statements.
True
You can use virtually any number of nested loops; however, at some point, your machine will no longer be able to store all the necessary looping information.
two semicolons
You must always include _____ in a for loop's parentheses.
Negative
You use a unary minus sign preceding a value to make the value ____.
Validating data
____ is the process of ensuring that a value falls within a specified range.
60
How many times will outputLabel be called? for(customer = 1; customer <= 20; ++customer) for(color = 1; color <= 3; ++color) outputLabel();
6
If g = 5, then after h = ++g, the value of h is _____.
false
If j = 5 and k = 6, then the value of j++ == k is _____.
9
If m = 9, then after n = m++, the value of n is _____.
total is equal to 300
If total = 100 and amt = 200, then after the statement total += amt, _____.
The loop control variable is false
In a dowhile loop, the loop will continue to execute until ____.
True
In order to improve loop performance, it's important to make sure the loop does not include unnecessary operations or statements.
7
In the expressions b = 8 and c = --b, what value will be assigned to the variable c?
Variable
It is important that the loop control ____ be altered within the body of the loop.
fusion
Loop _____ is the technique of combining two loops into one.
False
Making a comparison to 0 is slower than making a comparison to any other value.
False
Many seasoned programmers start counter values at 1 because they are used to doing so when working with arrays.
Pause
On many keyboards, the Break key is also the ____ key.
iteration
One execution of any loop is called a(n) _____.