Java - Switch case

Quiz
•
Computers
•
9th Grade
•
Easy
Vidya Byju
Used 2+ times
FREE Resource
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
Similar Resources on Wayground
10 questions
Java Print Statements Warm-Up

Quiz
•
9th - 12th Grade
8 questions
11-07 Output in Java

Quiz
•
9th Grade - University
10 questions
AP CS A Unit 7 Quiz PRACTICE

Quiz
•
9th - 12th Grade
6 questions
Методы+Массивы

Quiz
•
8th Grade - University
10 questions
Chapter 1 Study 2

Quiz
•
9th - 12th Grade
10 questions
Cybersecurity 2 Chapter 1 Quiz

Quiz
•
9th - 12th Grade
10 questions
Motherboard Mastery

Quiz
•
9th - 12th Grade
10 questions
Systemy operacyjne

Quiz
•
6th - 12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
Proper Keyboarding Techniques

Interactive video
•
6th - 10th Grade
14 questions
Inputs and Outputs: Computer Science Intro

Lesson
•
5th - 9th Grade
10 questions
Understanding Computers: Hardware, Software, and Operating Systems

Interactive video
•
7th - 12th Grade