📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    In a switch statement (e.g., C++, Java), what happens if

    a break statement is omitted from a case block?
    A A compilation error occurs. Correct Answer Incorrect Answer
    B The program terminates. Correct Answer Incorrect Answer
    C Execution "falls through" to the next case block. Correct Answer Incorrect Answer
    D The switch statement is skipped entirely. Correct Answer Incorrect Answer
    E The default block is always executed. Correct Answer Incorrect Answer

    Solution

    If break is omitted, after the matching case block executes, the program continues to execute the statements in the subsequent case blocks (and potentially the default block) until a break is encountered or the end of the switch statement is reached. This is known as "fall-through."

    Practice Next
    ask-question