LearnFrenzy
Sign in Take a free test

Conditional Statements · Conditional Statements MCQ · Question 3

Where can default go? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

Which statement about default in a switch is correct?

  • A It must be the last clause or a SyntaxError occurs
  • B It may appear anywhere and runs only if no case matches; without break it falls through into the cases after it Correct
  • C It always runs, even when a case matches
  • D A switch must contain a default
Correct Answer: Option B

default is chosen after all cases fail to match, wherever it is written. It is optional, and only one default is allowed.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links