Starting out with Java: Ch 4

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

The boolean expression in an if statement must evaluate to

true or false.

What would 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 would be the value of x after the following statements were executed? int x = 10; switch (x) { case 10: x += 15; case 12: x -= 5; break; default: x *= 3; }

20

What will be displayed when the following code is executed? double x = 45678.259; DecimalFormat formatter = new DecimalFormat("#,###,##0.00"); JOptionPane.showMessageDialog(null,formatter.format(x));

45,678.26

Enclosing a group of statements inside a set of braces creates

A block of statements

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

When two strings are compared using the String class's compareTo method, the comparison is case-insensitive.

False

If the expression on the left side of the && operator is false, the expression on the right side will not be checked.

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

Which of the following expressions determines whether the char variable chrA is not equal to the letter 'A'?

chrA != 'A'

Which of the following statements determines whether temp is within the range of 0 through 100?

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

If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal?

str1.equals(str2)

Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2?

str1.equalsIgnoreCase(str2)

A flag may have the values

true or false


Conjuntos de estudio relacionados

Chapter 27: Disorders of Cardiac Function, and Heart Failure and Circulatory Shock

View Set

FM 7-22 Physical Readiness Training

View Set

1. Sissejuhatus anatoomiasse ja füsioloogiasse

View Set

6.7 End of Topic Review--Test 6 - Training

View Set

COP 2500 Final Exam Review (pt.1/3)

View Set

Causes of the Texas Revolution: Study Guide

View Set

NUR 304 Chapter 60: Care of Patients with Acute Kidney Injury and Chronic Kidney Disease

View Set