Chapter 17 JAVA Flashcards
Evaluate the following expression:
1 + 2 == 3
A. true
B. false
C. unpredictable
A. true
Evaluate the following expression:
25 < 5 * 5
A. true
B. false
C. unpredictable
B. false
Evaluate the following expression:
8 + 1 >= 3 * 3
A. true
B. false
C. unpredictable
A. true
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.
D. Low bridge: proceed with caution.
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.
C. proceed with caution.
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.
C. Danger: deep water. No swimming allowed.
Evaluate the following expression:
10.0 + 0.10 < 11.0
A. true
B. false
C. unpredictable
A. true
Evaluate the following Java expression:
10.0 + 0.10 > 10.0
A. true
B. false
C. unpredictable
A. true
Evaluate the following Java expression:
10.0 + 1.0/10.0 < 10.1
A. true
B. false
C. unpredictable
C. unpredictable
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. >=
D. >=