Font size
WorksheetsTopic 4-2: Multiple if-else and switch-case
Total questions: 10
Worksheet time: 10mins
What value is assigned to fee by the multiple if-else statement when speed is 75?
40.00
60.00
20.00
error
What value is assigned to fee by the multiple if-else statement when speed is 75?
60.00
20.00
40.00
error
What is the output when the value of number is 20?
A
B
C
error
What is the output when the value of number is 10?
A
B
C
error
What is the output when the value of number is 50?
A
B
C
error
boolean attendance = true;
Which of the following if statement includes a condition that evaluates to true? (can select more than 1)
if(attendance) {...}
if(attendance == "true") {...}
if(attendance == true) {...}
if(attendance != false) {...}
Choose the correct syntax of SWITCH statement in Java below.
switch(input)
{
case constant1: //statements; break;
case constant2: //statements; break;
default: //statements;
};
switch(input)
{
case constant1: //statements; break;
case constant2: //statements; break;
default: //statements;
}
switch(input)
{
case constant1: //statements; break;
case constant2: //statements; break;
default case: //statements;
};
What is the output of Java program below?
int num=40;
switch(num)
{
case 5: System.out.println("FIVE"); break;
case 35+5: System.out.println("FORTY"); break;
case 20+30: System.out.println("FIFTY");
}
FIVE
FORTY
FIFTY
Error
What is the output of the below Java program?
int persons = 45;
int random = 45;
switch(random)
{
case persons: System.out.print("CRICKET ");
default: System.out.println("RUGBY");
}
CRICKET
CRICKET RUGBY
RUGBY
Compiler error
What is the output of the below Java program with a SWITCH statement?
int points=6;
switch(points)
{
case 6: ;
case 7: System.out.print("PASS");
case 8: ;
case 9: System.out.print(" Excellent");
case 10: System.out.print(" Outstanding"); break;
default: System.out.print("FAIL");
}
PASS Excellent Outstanding
Excellent
Outstanding
FAIL
