Question: 1. To test for equality between two values, use the ________ operator. 2. ________ can be omitted if they enclose a single statement in an
1. To test for equality between two values, use the ________ operator.
2. ________ can be omitted if they enclose a single statement in an if construct, but doing so is error-prone.
3. Complete the following if statement to test whether the expression number modulo 2 is equal to 0 (the variable name is number). Fill in the expression between the parentheses, use one space before the operator, after the operator, before the relational operator, and after the relational operator, with no other spaces or parentheses.
if (__________){
4. Complete the following if statement to test whether the radius of a circle is positive (assume the variable name is radius). Fill in the expression between the parentheses, use one space before the the relational operator, and one space after the relational operator, with no other spaces.
if (__________){
5. What will be displayed by the following code block?
A. apple, orange, pear
B. orange, pear
C. pear
D. apple, orange
6. If the variable income has the value is 4001, what is the output of the following code?
if (income > 3000) {
System.out.println("Income is greater than 3000");
}
else if (income > 4000) {
System.out.println("Income is greater than 4000");
}
A. no output
B. Income is greater than 3000
C. Income is greater than 3000 followed by Income is greater than 4000
D. Income is greater than 4000
E. Income is greater than 4000 followed by Income is greater than 3000
7. Assume x = 4 and y = 5, which of the following is true?
A. x
B. x
C. x > 5 && y > 5
D. x > 5 || y > 5
8. What is y after the following switch statement is executed?
int x = 3, y = 4; switch (x + 3) { case 6: y = 0; case 7: y = 1; default: y += 1; }
9. What is y after the following statement is executed?
x = 0; y = (x > 0) ? 10 : -10;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
