Question:

In Java, ................ statement is used to execute a block of code matching one value out of many possible values.

Show Hint

Use the switch statement in Java to handle multiple constant value conditions.
Updated On: Jul 14, 2025
  • if
  • for
  • while
  • switch
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

The switch statement in Java is used to evaluate an expression against multiple possible values and execute the corresponding code block.
It is a cleaner alternative to using multiple if-else-if statements when checking a variable for equality against several constant values.
Each possible value is defined using a case label, and the block executes if a match is found.
A default case can also be used when no match occurs.
Example:
switch(day)
case 1: {System.out.println("Monday");
break;}

The switch statement supports values like int, char, string, etc.
Hence, the correct answer is (D) switch.
Was this answer helpful?
0
0