QuestionQ98

Using Operators and Decision Constructs

Which assertion is correct about the switch statement?

  • A It must contain the default section.
  • B The break statement, at the end of each case block, is mandatory.
  • C Its case label literals can be changed at runtime.
  • D Its expression must evaluate to a single value.
Explanation

A switch statement evaluates its selector expression to a single value, which is compared with its case labels. A default section and break statements are optional, and case labels cannot be changed at runtime.

Community Discussion

No comments yet. Be the first to start the discussion!