Quiz 6
Quiz 6
True (*)
False
Correct Correct
Correct Correct
do-while
for
switch (*)
while
Incorrect Incorrect. Refer to Section 6 Lesson 1.
True
False (*)
Correct Correct
Correct Correct
6. You want to compute the sum of all the marks of a given subject. Which
approach will you choose? Mark for Review
(1) Points
switch statement
if/else statement
if statement
Looping (*)
Correct Correct
for (*)
do-while
while (*)
forEach
The body of a while loop eventually must make the condition false to avoid
infinite loop.
An infinite loop is a code which will execute until the user interrupts the
program
Correct Correct
Statements in the loop are executed repeatedly until the condition becomes
false.
Statements in the loop are executed once initially, and then the condition is
evaluated.
Statements in the loop are executed once until the condition becomes false.
The number of times a do-while loop is executed is dependent upon the value
of the counter variable. (*)
True
False (*)
If the condition of a pre-test loop is false, the statements in the loop are
never executed. (*)
The statement in a while loop will execute zero or more times. (*)
If the condition of the loop is true initially, the statements are never
executed.
Correct Correct
12. A while loop is often used with Scanner input as you don't know
many times you'll need to re-prompt the user if they type bad data. Mark for
Review
(1) Points
True (*)
False
Correct Correct
True (*)
False
Correct Correct
14. Which two statements are true about the break statement? Mark
for Review
(1) Points
The execution of the program will continue with the statement following the
loop-statement. (*)
The execution of the program will stop at the statement following the loop-
statement.
continue
catch
break (*)
Correct Correct
Section 6 Quiz
(Answer all questions in this section)
var1: 0, var2: 0
var1: 0, var2: 1
var1: 1, var2: 0
var1: 1, var2: 1
var1: 2, var2: 0
var1: 2, var2: 1
var1: 0, var2: 0
var1: 0, var2: 1
var1: 1, var2: 0
var1: 1, var2: 1
(*)
var1: 0, var2: 0
var1: 1, var2: 1
var1: 2, var2: 0
var1: 0, var2: 0
var1: 0, var2: 1
var1: 0, var2: 2
var1: 1, var2: 0
var1: 1, var2: 1
var1: 1, var2: 2
var1: 2, var2: 0
var1: 2, var2: 1
var1: 2, var2: 2
Correct Correct
2. The only way to exit a loop is for the loop condition to evaluate
to false. Mark for Review
(1) Points
True
False (*)
Correct Correct
3. Which two statements are true about the break statement? Mark
for Review
(1) Points
The execution of the program will continue with the statement following the
loop-statement. (*)
The execution of the program will stop at the statement following the loop-
statement.
Correct Correct
1 5 25 125
No output. (*)
1 5 25 125 175
5 25 125
Correct Correct
True (*)
False
Correct Correct
6. A pre-test loop evaluates the condition prior to execution of the loop.
Mark for Review
(1) Points
True (*)
False
Correct Correct
True (*)
False
Correct Correct
True
False (*)
Correct Correct
forEach
for (*)
while (*)
do-while
Correct Correct
10. Given:
Member
Global
Local (*)
Static
Correct Correct
11. The initialization expression initializes the loop and it is executed only
once, as the loop begins. Mark for Review
(1) Points
True (*)
False
Correct Correct
Correct Correct
13. In the given syntax of for loop, which part represents the header
section?
Code statement(s)
Correct Correct
do-while
for
switch (*)
while
Correct Correct
True
False (*)
Correct Correct