Question: QUESTION 1 Suppose x = 1, y = -1, and z = 1. What is the printout of the following statement? (Please indent the statement
QUESTION 1
Suppose x = 1, y = -1, and z = 1. What is the printout of the following statement? (Please indent the statement correctly first.) 
| x > 0 and y > 0; | ||
| x 0; | ||
| x | ||
| no printout. |
0.8 points
QUESTION 2
Analyze the following program fragment: 
| The program has a compile error because the required break statement is missing in the switch statement. | ||
| The program has a compile error because the required default case is missing in the switch statement. | ||
| The switch control variable cannot be double. | ||
| No errors. |
0.8 points
QUESTION 3
Analyze the following code: 
| The symbol x is always printed. | ||
| The value of variable x is always printed. | ||
| Nothing is printed because x > 0 is false. | ||
| The symbol x is always printed twice. |
0.8 points
QUESTION 4
Suppose x=10 and y=10. What is x after evaluating the expression (y >= 10) || (x-- > 10)?
| 9 | ||
| 10 | ||
| 11 |
0.8 points
QUESTION 5
What is 1
0.1 - 0.1 - 0.1 - 0.1 - 0.1 == 0.5?
| true | ||
| false | ||
| There is no guarantee that 1 |
0.8 points
QUESTION 6
Analyze the following code:
boolean even = (number % 2 == 0);
| Code 1 has compile errors. | ||
| Code 2 has compile errors. | ||
| Both Code 1 and Code 2 have compile errors. | ||
| Both Code 1 and Code 2 are correct, but Code 2 is better. |
0.8 points
QUESTION 7
Suppose income is 4001, what is the output of the following code? 
| no output | ||
| Income is greater than 3000 | ||
| Income is greater than 3000 followed by Income is greater than 4000 | ||
| Income is greater than 4000 | ||
| Income is greater than 4000 followed by Income is greater than 3000 |
0.8 points
QUESTION 8
You can cast a Boolean value to an int, or an int to Boolean.
| true | ||
| false |
0.8 points
QUESTION 9
Assume x = 4 and y = 5, which of the following is true?
| !(x == 4) ^ y != 5 | ||
| x != 4 ^ y == 5 | ||
| x == 5 ^ y == 4 | ||
| x != 5 ^ y != 4 |
0.8 points
QUESTION 10
The not equal comparison operator in Java is ________.
| != | ||
| != = | ||
| ^= |
0.8 points
QUESTION 11
In Java, the word true is ________.
| a Java keyword | ||
| a Boolean literal | ||
| same as value 1 | ||
| same as value 0 |
0.8 points
QUESTION 12
What is y after the following statement is executed? x = 0; y = (x > 0) ? 10 : -10;
| -10 | ||
| 0 | ||
| 10 | ||
| 20 | ||
| Illegal expression |
0.8 points
QUESTION 13
Assume x is 0. What is the output of the following statement? 
| x is greater than 0 | ||
| x is less than 0 | ||
| x equals 0 | ||
| None |
0.8 points
QUESTION 14
Analyze the following code: 
| y becomes 1 after the code is executed. | ||
| y becomes -1 after the code is executed. |
0.8 points
QUESTION 15
Suppose cond1, cond2, and cond3 are Boolean expressions. Which of the following expression is equivalent to cond1 || cond2 && cond3?
| (cond1 || cond2) && cond3 | ||
| cond1 || (cond2 && cond3) |
0.8 points
QUESTION 16
The "less than or equal to" comparison operator in Java is ________.
|
| ||
|
| ||
| = | ||
|
| ||
| != |
0.8 points
QUESTION 17
What is the output of the following code? (Please indent the statement correctly first.) 
| x > 9 and y > 8; | ||
| x = 7; | ||
| x | ||
| none |
0.8 points
QUESTION 18
Assume x = 4 and y = 5, which of the following is true?
| x | ||
| x | ||
| x > 5 && y > 5 | ||
| x > 5 || y > 5 |
0.8 points
QUESTION 19
What is 1 + 1 + 1 + 1 + 1 == 5?
| true | ||
| false | ||
| There is no guarantee that 1 + 1 + 1 + 1 + 1 == 5 is true. |
0.8 points
QUESTION 20
What is y after the following switch statement is executed? 
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 0 |
0.8 points
QUESTION 21
The ________ method immediately terminates the program.
| System.terminate(0); | ||
| System.halt(0); | ||
| System.exit(0); | ||
| System.quit(0); | ||
| System.stop(0); |
0.8 points
QUESTION 22
Given |x - 2|
| x - 2 = 4 | ||
| x - 2 -4 | ||
| x - 2 = -4 | ||
| x - 2 = -4 |
0.8 points
QUESTION 23
Which of the following operators are right-associative?
| * | ||
| + (binary +) | ||
| % | ||
| && | ||
| = |
0.8 points
QUESTION 24
Analyze the following code: 
| The program has a compile error. | ||
| The program has a runtime error. | ||
| The program runs fine, but displays nothing. | ||
| The program runs fine and displays It is even! |
0.8 points
QUESTION 25
Which of the following expressions evaluates to true?
| 'a' > 'A' | ||
| 34 > 34 | ||
| 'A' > 'z' | ||
| 2 > '2' |
0.8 points
QUESTION 26
Which of the following code displays the area of a circle if the radius is positive?
| if (radius != 0) System.out.println(radius * radius * 3.14159); | ||
| if (radius >= 0) System.out.println(radius * radius * 3.14159); | ||
| if (radius > 0) System.out.println(radius * radius * 3.14159); | ||
| if (radius |
0.8 points
QUESTION 27
Analyze the following code: boolean even = ((231 % 2) == 0); if (even = true) System.out.println("It is even!"); else System.out.println("It is odd!");
| The program has a syntax error | ||
| The program has a runtime error | ||
| The program displays "It is odd!" | ||
| The program displays "It is even!" |
0.8 points
QUESTION 28
Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative?
| 1 | ||
| ((x 1)) || (x | ||
| ((x 1)) && (x | ||
| (1 > x > 100) || (x |
0.8 points
QUESTION 29
What is y after the following switch statement? 
| 1 | ||
| -1 | ||
| 0 | ||
| 2 |
0.8 points
QUESTION 30
What is y displayed in the following code? 
| y is 0. | ||
| y is 1 because x is assigned to y first. | ||
| y is 2 because x + 1 is assigned to x and then x is assigned to y. | ||
| The program has a compile error since x is redeclared in the statement int y = x = x + 1. |
0.8 points
QUESTION 31
What is 1.0 + 1.0 + 1.0 == 3.0?
| true | ||
| false | ||
| There is no guarantee that 1.0 + 1.0 + 1.0 == 3.0 is true. |
0.8 points
QUESTION 32
The ________ operator can be used to compare two values.
| relational | ||
| boolean | ||
| numerical | ||
| casting |
0.8 points
QUESTION 33
The default case must be specified in a switch statement.
| true | ||
| false |
0.8 points
QUESTION 34
Suppose isPrime is a boolean variable, which of the following is the correct and best statement for testing if isPrime is true?
| if (isPrime = true) | ||
| if (isPrime == true) | ||
| if (isPrime) | ||
| if (!isPrime = false) | ||
| if (!isPrime == false) |
0.8 points
QUESTION 35
Given |x - 2| >= 4, which of the following is true?
| x - 2 >= 4 && x - 2 | ||
| x - 2 >= 4 || x - 2 | ||
| x - 2 >= 4 && x - 2 | ||
| x - 2 >= 4 || x - 2 |
0.8 points
QUESTION 36
The break keyword must be used in a switch statement; otherwise, a syntax error occurs.
| true | ||
| false |
0.8 points
QUESTION 37
In a switch statement, the default case must appear last among all cases. Otherwise, it would result in a compilation error.
| true | ||
| false |
0.8 points
QUESTION 38
Suppose x=0 and y=0. What is x after evaluating the expression (y > 0) && (1 > x++)?
| 0 | ||
| -1 | ||
| 1 |
0.8 points
QUESTION 39
What is x after evaluating the following? x = (2 > 3) ? 2 : 3;
| 2 | ||
| 3 | ||
| 4 | ||
| 5 |
0.8 points
QUESTION 40
Suppose you write the code to display "Cannot get a driver's license" if age is less than 16 and "Can get a driver's license" if age is greater than or equal to 16. Which of the following code is the best? 
| I | ||
| II | ||
| III | ||
| IV |
0.8 points
QUESTION 41
Suppose x=10 and y=10. What is x after evaluating the expression (y > 10) && (x-- > 10)?
| 9 | ||
| 10 | ||
| 11 |
0.8 points
QUESTION 42
Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative?
| 1 | ||
| ((x 1)) || (x | ||
| ((x 1)) && (x | ||
| (1 > x > 100) || (x |
0.8 points
QUESTION 43
Analyze the following code: 
| The if statement is wrong, because it does not have the else clause. | ||
| System.out.println(number); must be placed inside braces. | ||
| If number is zero, number is displayed. | ||
| If number is positive, number is displayed. | ||
| number entered from the input cannot be negative. |
0.8 points
QUESTION 44
The exclusive or (^) of true and true is true.
| true | ||
| false |
0.8 points
QUESTION 45
Suppose cond1 and cond2 are two Boolean expressions. When will this if condition be true? if (cond1 && cond2) ...
| in case cond1 is true and cond2 is false | ||
| in case cond1 is true and cond2 is true | ||
| in case cond1 is false and cond2 is false | ||
| in case cond1 is false and cond2 is true |
0.8 points
QUESTION 46
What is the output from System.out.println((int)Math.random() * 4)?
| 0 | ||
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
0.8 points
QUESTION 47
The order of the precedence (from high to low) of the operators binary +, *, &&, ||, & is ________.
| &&, ||, &, *, + | ||
| *, +, &&, ||, & | ||
| *, +, &, &&, || | ||
| *, +, &, ||, && | ||
| &, ||, &&, *, + |
0.8 points
QUESTION 48
You can always convert a switch statement to an equivalent if statement.
| true | ||
| false |
0.8 points
QUESTION 49
Analyze the following code: if (x 10) System.out.println("x is between 10 and 100");
| The statement has compile errors because (x 10) must be enclosed inside parentheses. | ||
| The statement has compile errors because (x 10) must be enclosed inside parentheses and the println( | ||
| The statement compiles fine. | ||
| The statement compiles fine, but has a runtime error. |
0.8 points
QUESTION 50
The following code displays ________. 
| too hot | ||
| too cold | ||
| just right | ||
| too hot too cold just right |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts

0.1 - 0.1 - 0.1 - 0.1 - 0.1 == 0.5 is true.
) statement must be put inside a block.