LearnFrenzy
Sign in Take a free test

Control Flow Statements · Control Flow MCQ · Question 19

When is switch better than if-else? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 19 Back to Exercise

When is a switch usually clearer than an if-else ladder?

  • A When comparing ranges like marks > 90
  • B When comparing one value against many constants (codes, enum constants, strings) Correct
  • C Never
  • D Only for booleans
Correct Answer: Option B

Range checks still need if (or guards in a pattern switch).

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