Java - Switch case
Quiz
•
Computers
•
9th Grade
•
Practice Problem
•
Easy
Vidya Byju
Used 2+ times
FREE Resource
Enhance your content in a minute
5 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In a switch case statement, what happens if none of the cases match the value of the expression?
The program terminates.
The default case is executed (if provided).
An error is generated.
The program goes into an infinite loop.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In a switch case statement, what is the purpose of the "case" keyword?
To specify a condition
To define a variable
To start a loop
To identify a code block to execute
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which data type is commonly used as the expression inside a switch case statement?
int
float
boolean
string
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
public static void main(String[] args) {
int score = 85;
switch (score / 10) {
case 10:
case 9:
System.out.println("A");
break;
case 8:
System.out.println("B");
case 7:
System.out.println("C");
break;
default:
System.out.println("D or F");
}
}
}
error
A
B
B
C
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
public static void main(String[] args) {
int num = 90; // ASCII 90 is Z
switch ((char) (num - 21)) {
case 'A':
System.out.println("Found A");
break;
case 'E':
System.out.println("Found E");
case 'I':
System.out.println("Found I");
break;
case 'Z':
System.out.println("Found Z");
break;
default:
System.out.println("Found something else");
}
}
}
Found Z
Found E
Found I
Error
Found something else
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Java Math
Quiz
•
1st - 12th Grade
10 questions
C# lesson10
Quiz
•
1st - 10th Grade
10 questions
Communication and Networking — Introduction to Email
Quiz
•
9th Grade
10 questions
Konsep Routing
Quiz
•
1st - 10th Grade
10 questions
1.1 - System Architecture - CPU [OCR] [GCSE]
Quiz
•
9th - 12th Grade
7 questions
Parts and Function of Respiratory System
Quiz
•
9th Grade
10 questions
Componentes red
Quiz
•
9th Grade
10 questions
Tes Sumatif Informatika
Quiz
•
7th Grade - University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
