Java chapter 4

¡Supera tus tareas y exámenes ahora con Quizwiz!

All it takes for an OR expression to be true is for one of the subexpressions to be true.

True

In a switch statement, each of the case values must be unique.

True

The if-else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false.

True

All it takes for an AND expression to be true is for one of the subexpressions to be true.

False

In a switch statement, if two different values for the CaseExpression would result in the same code being executed, you must have two copies of the code, one after each CaseExpression.

False

Programs never need more than one path of execution.

False

When testing for character values, the switch statement does not test for the case of the character.

False

A ________ is a boolean variable that signals when some condition exists in the program.

flag

The switch statement is a ________.

nested decision structure

A flag may have the values ________.

true or false

Which of the following is the not equal operator?

!=

What will be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 100; if (purchase > 1000) discountRate = 0.05; else if (purchase > 750) discountRate = 0.03; else if (purchase > 500) discountRate = 0.01;

0.0

What will be the value of bonus after the following statements are executed? int bonus, sales = 10000; if (sales < 5000) bonus = 200; else if (sales < 7500) bonus = 500; else if (sales < 10000) bonus = 750; else if (sales < 20000) bonus = 1000; elsebonus = 1250;

1000

If you prematurely terminate an if statement with a semicolon, the compiler will:

Assume you are placing a null statement there Not display an error message

________ works like this: If the expression on the left side of the && operator is false, the expression the right side will not be checked.

Short-circuit evaluation

What will be displayed after the following statements are executed?int ans = 10; int x = 65; int y = 55; if (x >= y) { int ans = x + y; } System.out.println(ans);

The code contains an error and will not compile. "int ans = x + y;" should not have "int" in it.

What will be the values of ans, x, and y after the following statements are executed? int ans = 35, x = 50, y = 50; if (x >= y) { ans = x + 10;x -= y; } else { ans = y + 10;y += x; }

ans = 60, x = 0, y = 50

The ________ statement is used to create a decision structure which allows a program to have more than one path of execution.

if

Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)?

if (temp >= 0 && temp <= 100)

In an if-else statement, if the boolean expression is false then ________.

the statement or block following the else is executed


Conjuntos de estudio relacionados

Contemporary Health Issues Test 3

View Set

Non-Infectious Upper Respiratory

View Set

Maryland Laws and Rules Pertinent to Property and Casualty Insurance

View Set

Individual Life Insurance Contract - Provision and Options

View Set

Early Childhood Studies Practice Test

View Set

Professional Selling Exam 2 (Ch. 4-7)

View Set