ExamTray App is now Available on Google Play EXAMTRAY android app link

 

TOTAL QS = 20Time [ 00 : 00 : 00 ]
00:00:00

Java Basics: Switch Case Statements Online Test 1

Instructions

Total Questions: 28

Total Minutes: 28

This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on Java Switch Case statements. This test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics.

Go through Java Theory Notes on Switch Case before attempting this test.

All the Best

Challenge SCORE

0 / 28

Take This Exam
1) A SWITCH case statement in Java is a ___ control statement.
2) Which is the alternative to SWITCH in Java language?
3) What are the keywords used to implement a SWITCH case in Java language?
4) What are the parts of a SWITCH in java?
5) A SWITCH statement accepts ___ type of data as input.
6) A switch statement in Java accepts ___ as input data.
7) Choose the correct syntax of SWITCH statement in Java below.
8) Which version of Java did start supporting String as the input data type of a SWITCH?
9) What is the output of Java program with SWITCH below?
int a=10;
switch(a)
{
case 10: System.out.println("TEN");
}
10) What is the output of the Java program below?
int b=20;
switch(b)
{
default: System.out.println("LION");
}
11) What is the output of the Java program below?
String animal = "GOAT";
switch(animal)
{
  break: System.out.println("DOMESTIC");
}
12) What is the output of the Java program below?
String college = "OXFORD";
switch("STANFORD")
{
case college: System.out.println("EXAM TIME"); break;
default: System.out.println("UNKNOWN");
}
13) 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");
}
14) 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");
}
15) 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");
}
16) What is the output of the below Java program?
switch(15)
{
  case 5*2: System.out.println("TEN");break;
  case 5*4-5:System.out.println("FIFTEEN");break;
  case 60/4+5: System.out.println("TWENTY");
}
17) A SWITCH fall through occurs in Java only in the absence of ___.
18) What is the purpose of designing a SWITCH logic with a fall-through in Java?
19) Does the following Java code-snippet compile?
switch(45)
{
  case 10: ;
}
20) What is the output of the below Java program with a SWITCH statement?
int points=6;
switch(points)
{
  case 6: ;
  case 7: System.out.println("PASS");break;
  case 8: ;
  case 9: System.out.println("Excellent");break;
  case 10: System.out.println("Outstanding"); break;
  default: System.out.println("FAIL");
}
21) Choose TRUE or FALSE. A SWITCH can be used to compare values for high or low.
22) State TRUE or FALSE. It is allowed to use duplicate case constants inside a Java SWITCH statement.
23) State TRUE or FALSE. SWITCH works faster than the IF-ELSE ladder in Java.
24) Choose the correct statement about Java SWITCH statements.
25) What is the output of the below Java program?
int hours = 10;
switch(hours)
{
  case 10: System.out.println("TEN");break;
  case 10: System.out.println("TEN AGAIN"); break;
  default: System.out.println("TEN AS USUAL");
}
26) What is the output of the below Java program?
char grade = 'B';
switch(grade)
{
  case 'A': System.out.print("GRADE-A ");break;
  case 'B': System.out.print("GRADE-B ");
  case 'C': System.out.print("GRADE-C ");
}
27) What is the output of the below Java program with SWICH and ENUM?
static enum ANIMAL {GOAT, TIGER, CAMEL}
public static void main(String args[])
{
  ANIMAL ani = ANIMAL.CAMEL;
  switch(ani)
  {
    case GOAT: System.out.println("GOAT");break;
    case CAMEL: System.out.println("CAMEL");break;
    case TIGER: System.out.println("TIGER");break;
  }

}
28) What is the output of the below Java program with SWITCH and Strings?
String phone = "APPLE";
switch(phone)
{
case "Apple": System.out.println("Apple");break;
case "APPLE": System.out.println("APPLE");break;
case "SAMSUNG": System.out.println("SAMSUNG");
}