Search Header Logo

Loops (Nested too)

Authored by Raymond Chan

Computers

9th - 12th Grade

Used 489+ times

Loops (Nested too)
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Media Image

What does the following code print?

5 4 3 2 1

-5 -4 -3 -2 -1

-4 -3 -2 -1 0

None of the above

2.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Media Image

Consider the following code segment. Which of the following can be used as a replacement for the missing loop header so that the loop prints out “0 2 4 6 8 10”?

while (count == 10)

while (count < 10)

while (count <= 10)

while (count > 10)

3.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Media Image

Consider the following code segment. What is count’s value after running this code segment?

0

1

16

6

4.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

What does the following code print?


for (int i = 3; i < 8; i++)

{

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

}

3 4 5 6 7 8

0 1 2 3 4 5 6 7 8

8 8 8 8 8

3 4 5 6 7

5.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Media Image

What does the following code print?

7 rows with 5 columns

7 rows with 4 columns

6 rows with 5 columns

6 rows with 4 columns

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What does the following code print?

A rectangle of 4 rows with 3 star per row.

A rectangle of 5 rows with 3 stars per row.

A rectangle of 4 rows with 1 star per row.

The loops have errors.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What are the values of var1 and var2 when the code finishes executing?

var1 = 1, var2 = 1

var1 = 2, var2 = 0

var1 = 3, var2 = -1

var1 = 0, var2 = 2

The loop will cause a run-time error with a division by zero.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?