switch statements + java

switch statements + java

Professional Development

82 Qs

quiz-placeholder

Similar activities

Dynamics BC365 - Basic Finance

Dynamics BC365 - Basic Finance

Professional Development

80 Qs

CAP II Part 3

CAP II Part 3

Professional Development

85 Qs

for-each loop + java

for-each loop + java

Professional Development

80 Qs

SAP FI - Certificate

SAP FI - Certificate

Professional Development

80 Qs

Operations Team Swiggy

Operations Team Swiggy

KG - Professional Development

85 Qs

Net 2 Certification

Net 2 Certification

Professional Development

82 Qs

switch statements + java

switch statements + java

Assessment

Quiz

Computers

Professional Development

Hard

Created by

ANIL KUMAR

FREE Resource

AI

Enhance your content

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

82 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Media Image
The following Java program uses a switch statement to print the current version of a programming language. Which programming language is the user input in the program?
Java
Python
Rust
JavaScript

Answer explanation

The program first asks the user to enter a programming language. Then, it uses a switch statement to check the user input. If the user input is "java", the program will print "Java Current Version is 12.". The other case statements in the switch statement are for Python, Rust, and a default case. Since the user input in the program is "java", the program will print the current version of Java.

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Media Image
Which of the following statements is printed when the variable n is equal to 10?
-10
-98
= -3
non of the above

Answer explanation

The switch statement in the image will first check if the value of n is equal to 10. If it is, the statement System.out.println("-10"); will be executed. The other statements will not be executed.

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Media Image
What is the output of the code in the image?
You are under 21
You are eligible for marriage now
You are over age
Invalid age

Answer explanation

You are eligible for marriage now. The switch statement in the image will first check if the value of the variable age is equal to 18. If it is, the statement System.out.println("You are eligible for marriage now"); will be executed. The other statements will not be executed.

4.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Media Image
What is the output of the code in the image when the value of num is 2?
Case1: Value is: 2
Case2: Value is: 2
Case3: Value is: 2
Default: Value is: 2

Answer explanation

The switch statement in the image will first check if the value of the variable num is equal to 1. If it is, the statement System.out.println("Case1: Value is: 1"); will be executed. However, the value of num is 2, so this case will not be executed.

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Media Image
What is the output of the code in the image when the value of weekday is 3?
Sunday
Monday
Tuesday
Invalid weekday

Answer explanation

The switch statement in the image will first check if the value of the variable weekday is equal to 1. If it is, the statement System.out.println("Sunday"); will be executed. However, the value of weekday is not equal to 1, so this case will not be executed.

6.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Media Image
Which of the following statements is printed when the value of n is 10?
-10
-98
= -3
none of the above

Answer explanation

The switch statement in the image will first check if the value of n is equal to 10. If it is, the statement System.out.println("-10"); will be executed. However, there is no case 10 in the switch statement, so this statement will not be executed.

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Media Image
What is the output of the code in the image when the value of n is 11?
-10
-98
= -3
11

Answer explanation

The switch statement in the image will first check if the value of n is equal to 11. If it is, the statement System.out.println(n); will be executed. This statement will print the value of n, which is 11.

Create a free account and access millions of resources

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

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?