Ch. 3 - Decision Structures

Ace your homework & exams now with Quizwiz!

Which of the following will format .1278 to display as 12.8%?

##0.0%

A Boolean expression is one that is either:

true or false

A flag may have the values:

true or false

Which one of the following is the not equal operator?

!=

In most editors, you are indenting by one level each time that you press this key:

Tab

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

True

TRUE/FALSE: 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

TRUE/FALSE: Because the && operator performs short-circuit evaluation, your boolean expression will usually execute faster if the subexpression that is most likely false is on the left of the && operator.

True

TRUE/FALSE: Because the || operator performs short-circuit evaluation, your boolean expression will generally be evaluated faster if the subexpression that is most likely to be true is on the left.

True

TRUE/FALSE: In a switch statement, each of the case values must be unique.

True

TRUE/FALSE: 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

TRUE/FALSE: Unicode is an international encoding system that is extensive enough to represent ALL the characters of ALL the world's alphabets.

True

In an if/else statement, if the boolean expression is false,:

the statement or block following the else is executed

The expression tested by an if statement must evaluate to:

true or false

Which of the following expressions will determine whether x is less than or equal to y?

x <= y

Enclosing a group of statements inside a set of braces creates a:

block of statements

Which of the following is the correct boolean expression to test for: int x being a value less than or equal to 500 or greater than 650, and int y not equal to 1000?

((x <= 500 || x > 650) && !(y == 1000))

Which of the following is the correct boolean expression to test for: int x being a value between, but not including, 500 and 650, or int y not equal to 1000?

((x > 500 && x < 650) || (y != 1000))

If str1 and str2 are both Strings, which of the following will correctly test to determine whether str1 is less than str2? (1) (str1 < str2) (2) (str1.equals(str2) < 0) (3) (str1.compareTo(str2) < 0)

3

Which of the following will format 12.78 to display as 012.8?

000.0

If str1 and str2 are both Strings, which of the following expressions will correctly determine whether they are equal? (1) (str1 == str2) (2) str1.equals(str2) (3) (str1.compareTo(str2) == 0)

2 and 3

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

All of the above (Not display an error message, Assume you are placing a null statement there)

These operators use two operands:

Binary

A block of code is enclosed in a set of:

Braces { }

TRUE/FALSE: An important style rule you should follow when writing if statements is to line up the conditionally executed statement with the if statement.

False

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

TRUE/FALSE: Programs never need more than one path of execution.

False

TRUE/FALSE: When testing for character values, the switch statement does not test for the case of the character.

False

TRUE/FALSE: When two Strings are compared using the compareTo method, the cases of the two strings are not considered.

False

This is a boolean variable that signals when some condition exists in the program:

Flag

The switch statement is a:

Multiple alternative decision structure

This type of operator determines whether a specific relationship exists between two values:

Relational

____________ 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

This is an international coding system that is extensive enough to represent all the characters of all the world's alphabets:

Unicode

In Java, when a character is stored in memory, it is actually stored as a:

Unicode number

To do a case insensitive compare which of the following could be used to test the equality of two strings, str1 and str2?

a & b *(str1.equalsIgnoreCase(str2)) & (str1.compareToIgnoreCase(str2) == 0)*

The _________ statement is used to make simple decisions in Java.

if

Which of the following correctly tests the char variable chr to determine whether it is not equal to the character B?

if (chr != 'B')

If chr is a character variable, which of the following if statements is written correctly?

if (chr == 'a')


Related study sets

Anatomy & Physiology I Lecture Exam 1 Review

View Set

Leadership, Delegation, & Prioritization

View Set

NCLEX EAQ module 8 Care Competencies

View Set

Chapter 24 Fundamentals of Nursing / Course Point Quiz 1

View Set

Cell Bio Final Review Nick and quiz

View Set