created: May 17, 1998

# Quiz: More Decisions

This is a practice quiz. The results are not recorded anywhere and do not affect your grade. The questions on this quiz might not appear in any quiz or test that does count toward your grade.

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 (to true or false) each of the following expressions:

```1 + 2 == 3      25 < 5 * 5      8 + 1 >= 3 * 3
```
 a.    true   true   true b.    true   true   false c.    true   false   true d.    false   true   true

2. Evaluate (to true or false) each of the following expressions:

```1 + 2 == (3 + 9) / 4     12 <= 2 + 2 * 3      2 * 2 + 5 != (1 + 2) * 3
```

 a.    false   false   false b.    false   false   true c.    false   true   false d.    true   false   false

3. 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.

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

```int height = 15;
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 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.    deep water. No swimming allowed. d.    Danger: deep water. No swimming allowed.

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

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

```
(Notice that changes have been made from the previous question.)

 a.    Danger: b.    No swimming allowed. c.    deep water. No swimming allowed. d.    Danger: deep water. No swimming allowed.

7. Evaluate (to true or false) each of the following expressions:

```10.0 + 0.10 < 11.0       10.0 + 0.10 > 10.0       10.0 + 0.10 == 10.1
```
 a.    true   true   unknown b.    true   true   true c.    unknown   unknown   unknown d.    false   true   true

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

```int age =  17 ;
if ( age  _________ 21 )
System.out.println("Care for some Grape Soda?");
else
```
 a.    < b.    == c.    != d.    >=

9. Fill in the blank so people under 21 years are offered Grape Soda. (Notice that the program is changed from the last question.)

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

 a.    < b.    == c.    != d.    >=

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

```int depth =  12 ;
int temp  =  42 ;

System.out.print("The water is: ")
if ( depth >= 8 )
System.out.print("deep ");

if ( temp <= 50 )
System.out.print("cold ");

System.out.println(" wet.");

```
 a.    The water is: b.    The water is: wet. c.    The water is: deep cold wet. d.    The water is wet cold deep.

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

 (If you have just 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 want to press the "shift key" while clicking on reload to clear the old answers.)