Java - Switch case

Java - Switch case

9th Grade

5 Qs

quiz-placeholder

Similar activities

ICT 9 Quiz 1

ICT 9 Quiz 1

9th Grade

10 Qs

Anime

Anime

KG - University

10 Qs

ÔN TÂP TIN 9

ÔN TÂP TIN 9

6th - 9th Grade

10 Qs

QBASIC Programming

QBASIC Programming

5th - 10th Grade

10 Qs

7.02 going online

7.02 going online

4th - 9th Grade

10 Qs

hardware and software(g3)

hardware and software(g3)

2nd - 10th Grade

10 Qs

DBMS- CLASS8 CBSE

DBMS- CLASS8 CBSE

7th - 10th Grade

10 Qs

JSPS Competition Hackathon - Scratch Language - Grade 1

JSPS Competition Hackathon - Scratch Language - Grade 1

2nd Grade - University

10 Qs

Java - Switch case

Java - Switch case

Assessment

Quiz

Computers

9th Grade

Practice Problem

Easy

Created by

Vidya Byju

Used 2+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?