Chapter 17 JAVA Flashcards

1
Q

Evaluate the following expression:

1 + 2 == 3
A. true

B. false

C. unpredictable

A

A. true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Evaluate the following expression:

25 < 5 * 5
A. true

B. false

C. unpredictable

A

B. false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Evaluate the following expression:

8 + 1 >= 3 * 3
A. true

B. false

C. unpredictable

A

A. true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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.

A

D. Low bridge: proceed with caution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.

A

C. proceed with caution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

C. Danger: deep water. No swimming allowed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Evaluate the following expression:

10.0 + 0.10 < 11.0
A. true

B. false

C. unpredictable

A

A. true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Evaluate the following Java expression:

10.0 + 0.10 > 10.0
A. true

B. false

C. unpredictable

A

A. true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Evaluate the following Java expression:

10.0 + 1.0/10.0 < 10.1
A. true

B. false

C. unpredictable

A

C. unpredictable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

if ( age _________ 21 )
System.out.println(“How about a Brew?”);
else
System.out.println(“Care for some Grape Soda?”);
A. <

B. ==

C. !=

D. >=

A

D. >=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly