created: 05/17/1998; revised: 10/04/03, 03/01/06

# on the Single-branch IF

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.

1. Evaluate the following expression:

```
1 + 2 == 3
```

A.    true

B.    false

C.    unpredictable

2. Evaluate the following expression:

```
25 < 5 * 5
```

A.    true

B.    false

C.    unpredictable

3. Evaluate the following expression:

```
8 + 1 >= 3 * 3
```

A.    true

B.    false

C.    unpredictable

4. What does the following code fragment write to the monitor?

```int height = 10;
if ( height <= 12 )
System.out.print("Low bridge: ");
System.out.println("proceed with caution.");
```

A.    Nothing is written.

B.    Low bridge:

C.    proceed with caution.

D.    Low bridge: proceed with caution.

5. What does the following code fragment write to the monitor?

```int height = 13;
if ( height <= 12 )
System.out.print("Low bridge: ");
System.out.println("proceed with caution.");
```

A.    Nothing is written.

B.    Low bridge:

C.    proceed with caution.

D.    Low bridge: proceed with caution.

6. What does the following code fragment write to the monitor?

```int depth =  8 ;
if ( depth >= 8 )
{
System.out.print("Danger: ");
System.out.print("deep water. ");
}
System.out.println("No swimming allowed.");
```

A.    Danger:

B.    Danger: deep water.

C.    Danger: deep water. No swimming allowed.

D.    deep water. No swimming allowed.

7. Evaluate the following expression:

```10.0 + 0.10 < 11.0
```

A.    true

B.    false

C.    unpredictable

8. Evaluate the following Java expression:

```10.0 + 0.10 > 10.0
```

A.    true

B.    false

C.    unpredictable

9. Evaluate the following Java expression:

```10.0 + 1.0/10.0 < 10.1
```

A.    true

B.    false

C.    unpredictable

10. Fill in the blank so people under 21 years are offered Grape Soda.

```if ( age  _________ 21 )
else
System.out.println("Care for some Grape Soda?");
```

A.    <

B.    ==

C.    !=

D.    >=

The number you got right:       Percent Correct:       Letter Grade:

If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may need to press the SHIFT KEY while clicking to clear the old answers.