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. What will be displayed by the following code block?

A. apple, orange, pear

B. orange, pear

C. pear

D. apple, orange

5. 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

6. 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; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!