Java Chapter 6

24 July 2022
4.7 (114 reviews)
55 test answers

Unlock all answers in this set

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