You are on page 1of 5

1. The only way to exit a loop is for the loop condition to evaluate to false.

Mark for Review

(1) Points
True
False (*)
Correct

2. A continue statement is used to skip the remaining statements in the body


of a loop and continue with the next iteration of the loop.
Mark for Review

(1) Points
True (*)

m
er as
False

co
Correct

eH w
o.
3. The purpose of adding comments is to increase the ability to understand
the logic easily. rs e
ou urc
Mark for Review

(1) Points
o
aC s

True (*)
vi y re

False
Correct
ed d

4. A while loop is often used with Scanner input as you don't know many
ar stu

times you'll need to re-prompt the user if they type bad data.
Mark for Review
is

(1) Points
True (*)
Th

False
Correct
sh

5. Which of the two are pre-test loops?


Mark for Review

(1) Points
do-while

This study source was downloaded by 100000837180363 from CourseHero.com on 11-19-2021 10:07:19 GMT -06:00

https://www.coursehero.com/file/69893204/JFo-Section-6-Quizdocx/
forEach
while(*)

for(*)
Correct
6. Which statement is true?
Mark for Review

(1) Points
The boolean expression that determines the number of loop iterations is
within the parentheses of a while loop. (*)
A counter (i) is declared and initialized inside the while loop.
A while loop boolean expression is made up of a counter, increment, and
test.

m
The counter which gets incremented determines the number of loop

er as
iterations is within the parentheses of a while loop.

co
eH w
Correct

o.
7. What is the output? rs e
ou urc
public static void main(String[] args) {
int num = 1;
o

while (num >= 200){


aC s

System.out.print(num + "" "");


vi y re

num = num * 5;
}
}
ed d

Mark for Review


ar stu

(1) Points
1 5 25 125 175
1 5 25 125
is

5 25 125
Th

No output. (*)
Correct
sh

8. The while loop continually executes a block of statements while a


particular condition is false.
Mark for Review

(1) Points

This study source was downloaded by 100000837180363 from CourseHero.com on 11-19-2021 10:07:19 GMT -06:00

https://www.coursehero.com/file/69893204/JFo-Section-6-Quizdocx/
True
False (*)
Correct

9. Which statement is NOT true about do-while loops?


Mark for Review

(1) Points
Statements in the loop are executed once until the condition becomes false.

Statements in the loop are executed repeatedly until the condition becomes
false.
The number of times a do-while loop is executed is dependent upon the
value of the counter variable. (*)

m
er as
Statements in the loop are executed once initially, and then the condition is

co
evaluated.

eH w
Correct

o.
rs e
10. Which statement will produce the output: 2, 4, 6, 8, 10?
ou urc
Mark for Review
o

(1) Points
for (int i = 0; i < 10; i += 2) {
aC s

System.out.print(i + " ");


vi y re

}
for (int i = 1; i < 10; i += 2) {
System.out.print(i + " ");
ed d

}
ar stu

for (int i = 0; i < 8; i += 2) {


System.out.print(i + " ");
}
is

for (int i = 2; i <= 10; i += 2) {


Th

System.out.print(i + " ");


} (*)
Correct
sh

11. Looping continues as long as the boolean expression in the for loop is
false.
Mark for Review

(1) Points

This study source was downloaded by 100000837180363 from CourseHero.com on 11-19-2021 10:07:19 GMT -06:00

https://www.coursehero.com/file/69893204/JFo-Section-6-Quizdocx/
True
False (*)
Correct

12. Loops are used in programs for repeated execution of one or more
statements until a terminating condition is reached.
Mark for Review

(1) Points
True (*)
False
Correct

m
13. Given:

er as
co
for(int i = 0; i > 10; i++){ }

eH w
What type of variable is i?

o.
Mark for Review rs e
ou urc
(1) Points
Member
o
aC s

Global
vi y re

Static
Local (*)
Correct
ed d
ar stu

14. The initialization expression initializes the loop and it is executed only
once, as the loop begins.
Mark for Review
is

(1) Points
Th

True (*)
False
Correct
sh

15. A for loop is also called a definite loop


Mark for Review

(1) Points

This study source was downloaded by 100000837180363 from CourseHero.com on 11-19-2021 10:07:19 GMT -06:00

https://www.coursehero.com/file/69893204/JFo-Section-6-Quizdocx/
True (*)
False
Correct

m
er as
co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

This study source was downloaded by 100000837180363 from CourseHero.com on 11-19-2021 10:07:19 GMT -06:00

https://www.coursehero.com/file/69893204/JFo-Section-6-Quizdocx/
Powered by TCPDF (www.tcpdf.org)

You might also like