Explore topic-wise MCQs in Compilers.

This section includes 22 Mcqs, each offering curated multiple-choice questions to sharpen your Compilers knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of the below Java program with SWITCH and Strings?

A. Apple
B. APPLE
C. SAMSUNG
D. Compiler error
Answer» C. SAMSUNG
2.

What is the output of the below Java program with SWICH and ENUM?

A. CAMEL
B. GOAT
C. TIGER
D. Compiler error
Answer» B. GOAT
3.

Choose the correct statement about Java SWITCH statements.

A. A SWITCH can contain another SWITCH statement.
B. Switch case statements are allowed inside IF-ELSE ladders.
C. Switch statements are allowed inside Loops like for, while and do while.
D. All
Answer» E.
4.

State TRUE or FALSE. SWITCH works faster than the IF-ELSE ladder in Java.

A. FALSE
B. TRUE
C. -
D. -
Answer» C. -
5.

State TRUE or FALSE. It is allowed to use duplicate case constants inside a Java SWITCH statement.

A. FALSE
B. TRUE
C. -
D. -
Answer» B. TRUE
6.

Choose TRUE or FALSE. A SWITCH can be used to compare values for high or low.

A. FALSE
B. TRUE
C. -
D. -
Answer» B. TRUE
7.

What is the output of the below Java program with a SWITCH statement?

A. PASS
B. Excellent
C. Outstanding
D. FAIL
Answer» B. Excellent
8.

Does the following Java code-snippet compile?

A. NO
B. YES
C. -
D. -
Answer» C. -
9.

What is the purpose of designing a SWITCH logic with a fall-through in Java?

A. To define ranges.
B. To define additions
C. To improve switch block performance
D. None
Answer» B. To define additions
10.

A SWITCH fall through occurs in Java only in the absence of ___.

A. case keyword
B. break keyword
C. default keyword
D. None
Answer» C. default keyword
11.

What is the output of Java program with SWITCH?

A. TEN
B. TWENTY
C. THIRTY
D. TEN TWENTY
Answer» C. THIRTY
12.

What is the output of Java program with SWITCH below?

A. No output
B. TEN
C. Compiler error as there is no BREAK.
D. None
Answer» C. Compiler error as there is no BREAK.
13.

Which version of Java did start supporting String as the input data type of a SWITCH?

A. JDK 5
B. JDK 6
C. JDK 7
D. JDK 8
Answer» D. JDK 8
14.

Choose the correct syntax of SWITCH statement in Java below.

A. switch(input)
B. switch(input)
C. switch(input)
D. switch(input)
Answer» C. switch(input)
15.

A switch statement in Java accepts ___ as input data.

A. enum
B. String
C. enum and String
D. long
Answer» D. long
16.

A SWITCH statement accepts ___ type of data as input.

A. byte
B. short
C. int
D. All
Answer» E.
17.

What are the parts of a SWITCH in java?

A. switch input condition
B. case constants
C. case statements
D. All
Answer» E.
18.

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

A. switch, case
B. default
C. break
D. All
Answer» E.
19.

Which is the alternative to SWITCH in Java language?

A. break, continue
B. for, while
C. if, else
D. goto, exit
Answer» D. goto, exit
20.

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

A. Iteration
B. Loop
C. Selection
D. Jump
Answer» D. Jump
21.

The statement for(;;) is perfectly valid C statemen?

A. True
B. False
Answer» C.
22.

The advantage of ‘switch’ statement over ‘if’ is that it leads to more structured program.$

A. True
B. False
Answer» C.