Tracing Loops in Java
3 days ago
olsonl
Save
Edit
Host a game
Live GameLive
Homework
Solo Practice
Practice
• Question 1
180 seconds
Q.

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 for division by zero

• Question 2
180 seconds
Q.

What are the values of x and y when the code finishes executing?

x = 5, y = 2

x = 2, y = 5

x = 3, y = 4

x = 4, y = 3

Infinite Loop

• Question 3
180 seconds
Q.

How many stars are printed?

7

3

4

5

Infinite Loop

• Question 4
180 seconds
Q.

In total, how many times is the inner loop executed?

5

10

15

50

Infinite Loop

• Question 5
180 seconds
Q.

How many times does the loop print a *

40

20

24

30

Infinite Loop

• Question 6
180 seconds
Q.

What does the following code print?

A rectangle of 8 rows with 5 stars per row

A rectangle of 8 rows with 4 stars per row

A rectangle of 6 rows with 5 stars per row

A rectangle of 6 rows with 4 stars per row

Infinite Looo

• Question 7
180 seconds
Q.

What does the following code print?

A rectangle of 9 rows with 5 stars per row

A rectangle of 6 rows with 6 stars per row

A rectangle of 7 rows with 5 stars per row

A rectangle of 7 rows with 6 stars per row

Infinite Loop

• Question 8
180 seconds
Q.

How many times is "HI!" printed?

15

12

10

8

Infinite Loop

• Question 9
180 seconds
Q.

What does the following code print?

5 6 7 8 9

4 5 6 7 8 9 10 11 12

3 5 7 9 11

3 4 5 6 7 8 9 10 11 12

• Question 10
180 seconds
Q.

How many times does the following method print a *?

9

6

7

10

• Question 11
180 seconds
Q.

What does the following code segment print?

5 4 3 2 1

-5 -4 -3 -2 -1

-4 -3 -2 -1 0

• Question 12
180 seconds
Q.

How many times does the code print a * ?

7

8

12

13

• Question 13
180 seconds
Q.

How many times does this print a * ?

4

5

6

7

• Question 14
180 seconds
Q.

How many times does this code print at * ?

5

6

7

8

• Question 15
180 seconds
Q.

What does the code print?

1 2 3 4

1 2 3 4 5

0 1 2 3 4

0 1 2 3 4 5

• Question 16
180 seconds
Q.

How many stars are printed?

10

5

25

50

• Question 17
180 seconds
Q.

What is printed when the code segment is executed?