computer science 12,13,14

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

In Java, the AND operation is requested using the operator__________

&&

How many choices are possible when using a single if-else statement?

2

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.");

deep water. No swimming allowed.

1+2 > 4-2 && 12 > 23 evaluates to

flase

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 System.out.println("How about a Brewski?");

<

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 ) System.out.println("How about a Brewski?"); else System.out.println("Care for some Grape Soda?");

>=

. 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.");

Danger: deep water. No swimming allowed.

True AND False=

Flase

Arithmetic operators (like *, +, -, /) have__________ precedence than other operators (like < , >, >=, &&, || ), so arithmetic is done___________ .

Higher, First

Relational operators (like < , >, >=, ) have_________ precedence than logical operators (like &&, || ), so comparing numbers is done________ . Since they have the lowest precedence the logical operators act______ .

Higher, Next <Last

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.");

Low bridge: proceed with caution.

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."); }

Nothing is written.

What does the following code fragment write to the monitor? int sum = 94; if ( sum < 20 ) { System.out.print("Under "); System.out.println("the limit."); } else { System.out.print("Over "); System.out.println("the limit."); } (Notice that the program has changed from the previous question!)

Over the limit

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.");

The water is: deep cold wet.

True OR false

True

Say that value has a 19 stored in it, and that extra has a 25 stored in it. Evaluate (to true or false) each of the following expressions: value <= extra extra < value value > -25 value >= extra

True false true false

What does the following code fragment write to the monitor? int sum = 14; if ( sum < 20 ) System.out.print("Under "); else { System.out.print("Over "); System.out.println("the limit."); } (Notice that the program has changed from the previous question!)

Under

What does the following code fragment write to the monitor? int sum = 14; if ( sum < 20 ) System.out.print("Under "); else System.out.print("Over "); System.out.println("the limit.");

Under the limit

What does the following code fragment write to the monitor? int sum = 7; if ( sum > 20 ) { System.out.print("You win "); } else { System.out.print("You lose "); } System.out.println("the prize."); (Notice that the program has changed from the previous question!)

You lose the prize

What does the following code fragment write to the monitor? int sum = 21; if ( sum != 20 ) System.out.print("You win "); else System.out.print("You lose "); System.out.println("the prize."); (Notice that the program has changed from the previous question!)

You win the prize

A sequence of statements contained within a pair of braces ("{" and "}") is called a:

block

+2 > 4-2 || 12 > 23 evaluates to

true

1+2 > 4-2 && 12 < 23 evaluates to

true

1+2 > 4-2 || 12 < 23 evaluates to

true

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

true false false

Evaluate (to true or false) each of the following expressions: 1 + 2 == 3 25 < 5 * 5 8 + 1 >= 3 * 3

true false true

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

true true unknown

In Java, the OR operation is requested using the operator _________

||


Set pelajaran terkait

Anthropology 1050 Exam 4 Study Guide Chapter 16

View Set

Econ Chapter 9: Economies of Scale and Scope

View Set

Chapter 62 - Care of Patients with Pituitary and Adrenal Gland Problems

View Set

HIST 150 Chapter 15: Reordering the World, 1750-1850

View Set

Principles of Insurance and General Insurance

View Set