Self-Quiz 1 Control Structures (If, Do, While, and For) Attempt Review
Self-Quiz 1 Control Structures (If, Do, While, and For) Attempt Review
Question 1
Correct
Select one:
a. sequence
b. selection
d. repetition
1 of 8 05-Dec-22, 9:57 PM
Self-Quiz 1: Control structures (if, do, while, and for): Attempt review https://my.uopeople.edu/mod/quiz/review.php?attempt=9254118&cmi...
Question 2
Correct
Given that n and count are both of type int, which statement is true about the following code segments?
II count = 1;
while (count <= n)
{
System.out.println(count);
count++;
}
Select one:
a. I and II are exactly equivalent for all input values of n.
b. I and II are exactly equivalent for all input values n>= 1, but differ when n<= 0.
2 of 8 05-Dec-22, 9:57 PM
Self-Quiz 1: Control structures (if, do, while, and for): Attempt review https://my.uopeople.edu/mod/quiz/review.php?attempt=9254118&cmi...
Question 3
Correct
Select one:
a. 4 16
b. 4 10 16
c. 0 6 12 18
3 of 8 05-Dec-22, 9:57 PM
Self-Quiz 1: Control structures (if, do, while, and for): Attempt review https://my.uopeople.edu/mod/quiz/review.php?attempt=9254118&cmi...
Question 4
Correct
c=1;
switch (c) {
case 1:
print '1';
case 2:
print '2';
break;
case 3:
print '3';
break;
}
Select one:
a. 123
b. 1
c. 12
d. 2 3
4 of 8 05-Dec-22, 9:57 PM
Self-Quiz 1: Control structures (if, do, while, and for): Attempt review https://my.uopeople.edu/mod/quiz/review.php?attempt=9254118&cmi...
Question 5
Correct
if n is of type int and has a value of 0 when the segment is executed, what will happen?
Select one:
a. Neither statement1 nor statement2 will be executed; control will pass to the first statement following the
if statement
5 of 8 05-Dec-22, 9:57 PM
Self-Quiz 1: Control structures (if, do, while, and for): Attempt review https://my.uopeople.edu/mod/quiz/review.php?attempt=9254118&cmi...
Question 6
Correct
What will the output be for the following poorly formatted program segment, if the input value for num is 22?
Select one:
a. 22
b. 4
c. 22 is negative
d. 2 is negative
Jump to...
6 of 8 05-Dec-22, 9:57 PM
Self-Quiz 1: Control structures (if, do, while, and for): Attempt review https://my.uopeople.edu/mod/quiz/review.php?attempt=9254118&cmi...
Question 7
Correct
The output of compilation is code generation which typically translates a language construct into assembly
language and from there into machine executable code. What language construct was the following segment of
assembler code generated from?
compute R1,expression
jump.eq R1,L1
statement-1
jump L2
L1: statement-2
L2:
Select one:
a. while statement
c. case statement
d. if statement
Question 8
Correct
The correct looping statement to use when the number of iterations is known is:
Select one:
a. The for loop
7 of 8 05-Dec-22, 9:57 PM
Self-Quiz 1: Control structures (if, do, while, and for): Attempt review https://my.uopeople.edu/mod/quiz/review.php?attempt=9254118&cmi...
Question 9
Correct
The ___ statement implements a pre-test loop that is used when the number of iterations is NOT known.
Answer: while
Question 10
Correct
True/False: The switch/case statement is an example of the sequence structure implemented within a
programming language?
Select one:
True
False
Question 11
Correct
Select one:
True
False
8 of 8 05-Dec-22, 9:57 PM