Java Chapter 4 Review

Ace your homework & exams now with Quizwiz!

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8%?

"##0.0%"

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 012.8?

"000.0"

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8%?

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

2

What will be displayed when the following code is executed? int y = 10; if (y == 10) { int x = 30; x += y; system.out.println(x);

40

________ operators are used to determine whether a specific relationship exists between two values.

Relational

When a character is stored in memory, it is actually the ________ that is stored.

Unicode number

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.

fale

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

false

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)

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

the statement or block following the else is executed.

A local variable's scope always ends at the closing brace of the block of code in which it is declared.

true

An important style rule you should adopt for writing if statements is to write the conditionally executed statement on the line after the if statement.

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

Unicode is an international encoding system that is extensive enough to represent all the characters of all the world's alphabets.

true

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

true

A flag may have the values

true or false


Related study sets

5. Relational Databases and mySQL

View Set

ECO-251: Chapter 1 - Limits, Alternatives, and Choices

View Set

TBR Psych 3 - Learning and Memory

View Set

Experimental Psychology '19 Review Questions - 1st Exam

View Set