WorksheetsJava Lesson 6
Total questions: 8
Worksheet time: 4mins
A SWITCH case statement in Java is a ___ control statement.
Iteration
Looping
Selection
Jump
What are the keywords used to implement a SWITCH case in Java language?
switch, case
default
break
All of above
A SWITCH statement accepts ___ type of data as input.
byte
short
int
String (case sensitive)
All of above
What is the output of Java program with SWITCH below?
int a=10;
switch(a)
{
case 2: System.out.println("TWO");
break;
case 10: System.out.println("TEN");
break;
}
No Output
TEN
Compiler error as there is no break
None
What is the output of the Java program below?
int b=20;
switch(b)
{
default: System.out.println("LION");
}
No Output
LION
Compiler error as there are no CASE statements.
None
What is the output of Java program with SWITCH?
int num=20;
switch(num)
{
case 10: System.out.println("TEN"); break;
case 20: System.out.println("TWENTY"); break;
case 30: System.out.println("THIRTY");
}
TEN
TWENTY
THIRTY
TEN TWENTY
A SWITCH fall through (keeps going onto the next case) occurs in Java only in the absence of a ___.
Keyword "case"
Keyword "break"
Keyword "default"
None of these
What type of literal is "null"?
null Literal
Character Literal
String Literal
It is not a Literal
