Multiple Choice
Given the following switch statement where x is an int, answer the questions below
switch (x)
{
case 3 : x += 1;
case 4 : x += 2;
case 5 : x += 3;
case 6 : x++;
case 7 : x += 2;
case 8 : x--;
case 9 : x++
}
-The statement if (x < 0) y = x; else y = 0; can be rewritten using a conditional operator as
A) y = (x < 0) ? x : 0;
B) x = (x < 0) ? y : 0;
C) (x < 0) ? y = x : y = 0;
D) y = (x < 0) ;
E) y = if (x < 0) x : 0;
Correct Answer:

Verified
Correct Answer:
Verified
Q1: Each case in a switch statement must
Q2: Rewrite the following nested if-else statement as
Q3: Consider the following paint method to answer
Q4: Write a paint method to draw out
Q7: How many times will the following loop
Q8: It is possible to convert any type
Q9: Consider the following paint method to answer
Q10: A continue statement<br>A) may be used within
Q11: Given that s is a String, what
Q16: In Java, it is possible to create