Switch case statement fallthrough

Q.  Fallthrough in a switch case statement
- Published on 19 Oct 15

a. prevents the next case after the matching block to be executed
b. Allows the next case after the matching block to be executed
c. no fallthorugh occurs in switch case
d. none

ANSWER: Allows the next case after the matching block to be executed
 
When break statement is not present in the switch case code block, after executing the matching block the execution continues to execute the next case(fallthrough). Thus fallthrough is a situation which allows multiple values to match the same point without any special syntax. In practice, the break statement after execution of the required code(matching block) exits the switch block. This prevents the fallthrough. C# is a language that has made usage of break statement in coding , a mandatory. Compilation of code without break statement throws error and hence prevents fallthrough.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)