wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Lesson 6

Total questions: 8

Worksheet time: 4mins

Name
Class
Date
1.

A SWITCH case statement in Java is a ___ control statement.

a)

Iteration

b)

Looping

c)

Selection

d)

Jump

2.

What are the keywords used to implement a SWITCH case in Java language?

a)

switch, case

b)

default

c)

break

d)

All of above

3.

A SWITCH statement accepts ___ type of data as input.

a)

byte

b)

short

c)

int

d)

String (case sensitive)

e)

All of above

4.

What is the output of Java program with SWITCH below?


int a=10;

switch(a)

{

case 2: System.out.println("TWO");

break;

case 10: System.out.println("TEN");

break;

}

a)

No Output

b)

TEN

c)

Compiler error as there is no break

d)

None

5.

What is the output of the Java program below?


int b=20;

switch(b)

{

default: System.out.println("LION");

}

a)

No Output

b)

LION

c)

Compiler error as there are no CASE statements.

d)

None

6.

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");

}

a)

TEN

b)

TWENTY

c)

THIRTY

d)

TEN TWENTY

7.

A SWITCH fall through (keeps going onto the next case) occurs in Java only in the absence of a ___.

a)

Keyword "case"

b)

Keyword "break"

c)

Keyword "default"

d)

None of these

8.

What type of literal is "null"?

a)

null Literal

b)

Character Literal

c)

String Literal

d)

It is not a Literal