KnowledgeBoat Logo
|

Computer Applications

Assertion (A): In switch case, break statement avoids fall through.

Reason (R): break statement helps to execute only one case at a time.

  1. Both (A) and (R) are true and (R) is a correct explanation of (A).
  2. Both (A) and (R) are true and (R) is not a correct explanation of (A).
  3. (A) is true and (R) is false.
  4. (A) is false and (R) is true.

Java Conditional Stmts

5 Likes

Answer

Both (A) and (R) are true and (R) is a correct explanation of (A).

Reason — In a switch case, the break statement stops the program from executing the next cases after a match is found. Without the break, the program would continue to run all the cases below the matched one (called fall through). Therefore, the break statement helps to execute only one case at a time.

Answered By

2 Likes


Related Questions