KnowledgeBoat Logo

Computer Applications

Which of the following is true about the default label in a switch statement?

Java Conditional Stmts

2 Likes

Answer

It executes if no matching case label is found.

Reason — The default label in a switch statement is used as a fallback option. If none of the case labels match the switch expression, the default block executes.

  • Including a default label is optional in a switch statement.
  • It can appear anywhere within the switch block.
  • The default label can appear only once, but its position within the switch block is flexible (not restricted to the top).

Answered By

2 Likes


Related Questions