Java Chapter 5

25 July 2022
4.7 (114 reviews)
54 test answers

Unlock all answers in this set

Unlock answers (50)
question
Flowchart
answer
A ____ consists of written steps in diagram form, as a series of shapes connected by arrows.
question
Sequence
answer
A logical structure called a(n) ____ structure is when one step follows another unconditionally.
question
If
answer
The simplest statement you can use to make a decision is the ____ statement.
question
Single equal sign
answer
When an expression containing a ____ is part of an if statement, the assignment is illegal.
question
dual-alternative if
answer
(n) ____ statement is the decision structure you use when you need to take one or the other of two possible courses of action.
question
Boolean expression
answer
When you execute an ifelse statement, only one of the resulting actions takes place depending on the evaluation of the ____ following the if.
question
Curly braces
answer
When you place a block within an if statement, it is crucial to place the ____ correctly.
question
Else
answer
Just as you can block statements that depend on an if, you can also block statements that depend on a(n) ____.
question
Variable
answer
When you block statements, you must remember that any ____ you declare within a block is local to that block.
question
Nested
answer
Statements in which an if structure is contained inside another if structure are commonly called ____ if statements.
question
Logic
answer
The compiler does not take indentation into account when compiling code, but consistent indentation can help readers understand a program's ____.
question
Ampersands
answer
The AND operator is written as two ____.
question
Boolean expression
answer
When you use the && operator, you must include a complete _____ on each side.
question
Conditional OR operator
answer
You can use the ____, which is written as ||, if you want some action to occur when at least one of two conditions is true.
question
Range check
answer
A(n) ____ is a series of if statements that determine whether a value falls within a specified range.
question
Switch
answer
The ____ statement is useful when you need to test a single variable against a series of exact integer, character, or string values.
question
Break
answer
You can leave out the ____ statements in a switch structure.
question
Conditional opertator
answer
The ____ requires three expressions separated with a question mark and a colon.The ____ operator is written as the exclamation point ( ! ).
question
NOT
answer
The ____ operator is always evaluated before the OR operator.
question
Parentheses
answer
When working with logical operators, you can always use ____ to change precedence.
question
Decision structure
answer
A ____ checks a value, and based on the result performs one of two actions.
question
hoursWorked >= FULL_WEEK
answer
Using the flowchart above, which decision statement will correctly check that hoursWorked is greater than or equal to the FULL_WEEK constant?
question
&&
answer
if (quotaAmt > 100 || sales > 100 && productCode == "C") bonusAmt = 50; When the above code is executed, which operator is evaluated first?
question
Memory addresses
answer
When using equals and not equals for comparisons with objects, you compare the objects' ____ instead of actual values.
question
True
answer
You write pseudocode in everyday language, not the syntax used in a programming language.
question
True
answer
An alternative to using a Boolean expression, such as someVariable == 10, is to store the Boolean expression's value in a Boolean variable.
question
False
answer
When you create a block, you must place multiple statements within it.
question
True
answer
When you use nested if statements, you must pay careful attention to placement of any else clauses.
question
False
answer
In the switch structure, break is followed by one of the possible values for the test expression and a colon.
question
True
answer
Computers contain switches that are set to on or off.
question
False
answer
When writing a statement with the two-line format, you must be sure to type a semicolon at the end of the first line in order to ensure accurate results.
question
False
answer
Although it is possible to block statements that depend on an if, you cannot likewise block statements that depend on an else.
question
True
answer
Although not required, it is common procedure to align the keyword if with the keyword else.
question
True
answer
You use the NOT operator, which is written as the exclamation point (!), to negate the result of any Boolean expression.
question
sequence
answer
The logical structure in which one instruction occurs after another with no branching is a _____.
question
diamond
answer
Which of the following is typically used in a flowchart to indicate a decision?
question
single-alternative selection
answer
An if statement is sometimes called a _____.
question
only one of the resulting actions
answer
When you execute an if...else statement, _____ takes place depending on the evaluation of the Boolean expression.
question
false
answer
In Java, the value of (4 > 7) is _____.
question
curly braces
answer
If you want to take more than one action following the evaluation of a Boolean expression within an if statement, you use a pair of _____ to place the dependent statements within a block.
question
is local to that block
answer
When you declare a variable within a block, it _____.
question
nested
answer
Statements in which an if statement is contained inside another if statement commonly are called _____ if statements.
question
Compound
answer
An expression that combines Boolean tests into a single expression using the logical AND and OR operators are known as a(n) _____ condition.
question
range check
answer
A _____ is a series of statements that determine to which of several consecutive series of values another value falls.
question
&&
answer
The operator that combines two conditions into a single Boolean value that is true only when both of the conditions are true, but is false otherwise, is _____.
question
||
answer
The operator that combines two conditions into a single Boolean value that is true when at least one of the conditions is true is _____.
question
All of the above statements set g to 0
answer
Assuming a variable f has been initialized to 5, which of the following statements sets g to 0?
question
logical OR
answer
Which of the following groups has the lowest operator precedence?
question
true
answer
When you must make a series of decisions in a program, it is most efficient to first ask the question that is most likely to be _____.
question
short-circuit evaluation
answer
The _____ feature is one in which expressions on each side of the && and || operators are evaluated only as far as necessary to determine whether the entire expression is true or false.
question
break
answer
You can use the _____ statement to terminate a switch structure.
question
double
answer
The switch statement is useful when you need to test a single variable against a series of any of the following values except a(n) _____.
question
testExpression ? trueResult : falseResult;
answer
Which of the following shows the correct syntax for the conditional operator?
question
false
answer
Assuming a variable y has been assigned the value 6, the value of !(y < 7) is _____.