0% found this document useful (0 votes)
118 views

Self-Quiz 1 Control Structures (If, Do, While, and For) Attempt Review

This document is a review of a student's attempt on a self-quiz about control structures in programming like if/else statements, loops, and switch cases. The student answered 11 multiple choice questions correctly, completing the quiz in under 9 minutes with a perfect score of 11 out of 11 and a grade of 10 out of 10.

Uploaded by

Khaled kabboush
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views

Self-Quiz 1 Control Structures (If, Do, While, and For) Attempt Review

This document is a review of a student's attempt on a self-quiz about control structures in programming like if/else statements, loops, and switch cases. The student answered 11 multiple choice questions correctly, completing the quiz in under 9 minutes with a perfect score of 11 out of 11 and a grade of 10 out of 10.

Uploaded by

Khaled kabboush
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Self-Quiz 1: Control structures (if, do, while, and for): Attempt review https://my.uopeople.edu/mod/quiz/review.php?attempt=9254118&cmi...

Dashboard / My courses / CS 4402-01 - AY2023-T2 / 1 December - 7 December

/ Self-Quiz 1: Control structures (if, do, while, and for)

Started on Monday, 5 December 2022, 1:48 PM


State Finished
Completed on Monday, 5 December 2022, 1:57 PM
Time taken 8 mins 34 secs
Marks 11.00/11.00
Grade 10.00 out of 10.00 (100%)

Question 1
Correct

Mark 1.00 out of 1.00

Which of the following is NOT a programming structure?

Select one:
a. sequence

b. selection

c. object oriented programming 

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

Mark 1.00 out of 1.00

Given that n and count are both of type int, which statement is true about the following code segments?

I        for (count=1; count <= n; count++)


                System.out.println(count);

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.

c. I and II are exactly equivalent only when n = 0. 

d. I and II are exactly equivalent only when n is even.

e. I and II are not equivalent for any input values of n. 

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

Mark 1.00 out of 1.00

Consider the following code segment:

for (int k=0; k<20; k=k+2)


{
     if (k%3 == 1)
           System.out.print(k+"  ");
}

What is printed when this code is executed? 

Select one:
a. 4  16

b. 4  10  16 

c. 0  6  12  18

d. 1  4  7  10  13  16  19

e. 0  2  4  6  8  10  12  14  16  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

Mark 1.00 out of 1.00

What will the output of the following code be?

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

Mark 1.00 out of 1.00

Consider the following code segment

if (n != 0 && n / n > 1000)


    statement1;
else
    statement2;

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

b. A syntax error will occur

c. statement1, but not statement2, will be executed

d. statement2, but not statement1 will be executed 

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

Mark 1.00 out of 1.00

What will the output be for the following poorly formatted program segment, if the input value for num is 22?

int num = call to a method that reads an integer;


if(num>0)
if(num%5 ==0)
System.out.println(num);
else System.out.println(num+" is negative");
 

Select one:
a. 22

b. 4

c. 22 is negative 

d. 2 is negative

◄ Learning Journal Unit 4

Jump to...

Self-Quiz 2: Subroutines, procedures, functions, parameters, call by value or reference ►

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

Mark 1.00 out of 1.00

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

b. for loop statement

c. case statement

d. if statement 

Question 8
Correct

Mark 1.00 out of 1.00

The correct looping statement to use when the number of iterations is known is:

Select one:
a. The for loop 

b. The while loop

c. The do .. while loop

d. None of these answers

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

Mark 1.00 out of 1.00

The ___ statement implements a pre-test loop that is used when the number of iterations is NOT known. 

Answer: while 

Question 10
Correct

Mark 1.00 out of 1.00

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

Mark 1.00 out of 1.00

True/False: Loop statements are the most difficult statements to program.

Select one:
True 

False

8 of 8 05-Dec-22, 9:57 PM

You might also like