java chp 5
The operator that combines two conditions into a single Boolean value that is true only when both of the conditions are true is ____________.
&&
What is the output of the following code segment? t = 10;if(t > 7){System.out.print("AAA");System.out.print("BBB");}
AAABBB
Assuming the variable score has been assigned the value 9, which of the following statements displays XXX?
All of the above display XXX.
Assuming a variable f has been initialized to 5, which of the following statements sets g to 0?
All of the above statements set g to 0.
What is the output of the following code segment? t = 0; if(t > 7) System.out.print("AAA"); System.out.print("BBB");
BBB
There are three types of if statements: single-alternative, dual-alternative, and reverse.
False
You can use the exit statement to terminate a switch statement.
False
In Java, decisions are based on a Boolean value.
True
When you code an if statement within another if statement, the statements are nested.
True
Assuming a variable w has been assigned the value 15, what does the following statement do? w == 15 ? x = 2 : x = 0;
assigns 2 to x
Which of the following is typically used in a flowchart to indicate a decision?
diamond
Which of the following cannot be the argument tested in a switch statement?
double
Assuming a variable y has been assigned the value 6, the value of !(y < 7) is ____________.
false
Which of the following statements correctly outputs the names of voters who live in district 6 and all voters who live in district 7?
if(district == 6 || district == 7) System.out.println("Name is " + name);
Which of the following displays Error when a student ID is less than 1000 or more than 9999?
if(stuId < 1000) System.out.println("Error");
What is the output of the following code segment? t = 7;if(t > 7){System.out.print("AAA");System.out.print("BBB");}
nothing
The logical structure in which one instruction occurs after another with no branching is a ____________.
sequence
In Java, the value of (14 > 7) is ____________.
true
The operator that combines two conditions into a single Boolean value that is true when at least one of the conditions is true is ____________.
||
Which of the following has the lowest precedence?
||