Question
int i = l, j = -1;
switch (i)
{
case 0, 1: j = 1; /* Line 4 */
case 2: j = 2;
default: j = 0;
}
System.out.println("j = " + j);
What will be the output of the program?
int i = l, j = -1;
switch (i)
{
case 0, 1: j = 1; /* Line 4 */
case 2: j = 2;
default: j = 0;
}
System.out.println("j = " + j);
Answer: Option D
Was this answer helpful ?
The case statement takes only a single argument. The case statement on line 4 is
given two arguments so the compiler complains.
Was this answer helpful ?
More Questions on This Topic :
Question 1.
public class While
{
public void loop()
{
....
Question 2.
switch(x)
{
default:
System.out.println("....
Submit Solution