ICSE Class 9 Computer Applications
Question 5 of 17
Conditional Constructs in Java — Question 5
Back to all questions 5
Question Question 5
Write the following switch statement by using nested if statements:
switch (choice)
{
case 0:
case 1:
x = 11;
y = 22;
break;
case 2:
x = 33;
y = 44;
break;
default:
y = 55;
break;
}if (choice == 0 || choice == 1)
{
x = 11;
y = 22;
}
else
{
if (choice == 2)
{
x = 33;
y = 44;
}
else
{
y = 55;
}
}