C#.NET — Control flow semantics: switch, goto/continue, jump statements, and do loops. Which statements are correct?

Difficulty: Easy

Correct Answer: 1, 3, 5

Explanation:


Introduction / Context:
This conceptual item asks you to pick the accurate descriptions of several C# control-flow constructs: switch, jump statements (break/continue/goto/return), and the do loop. The distractors intentionally conflate goto and continue behaviors with switch case labels.


Given Data / Assumptions:

  • Five statements cover switch, goto, jump semantics, continue, and do.


Concept / Approach:
Recall: switch selects among cases; jump statements cause immediate transfers of control; continue skips to the next iteration of the current loop, not to a switch label; the do statement executes the body at least once, then repeats until the expression becomes false.


Step-by-Step Solution:

1) Correct — switch handles multiple selections via case labels (and can be used with enums). 2) Incorrect — goto does not inherently “go to next iteration”; that is continue. Plain goto transfers to a label. 3) Correct — break/continue/goto/return are jump statements that transfer control immediately. 4) Incorrect — continue does not target switch labels; use goto case/goto default within switch. 5) Correct — do { ... } while (expr); repeats until expr evaluates to false.


Verification / Alternative check:
Write micro-examples using each construct and observe the control flow in a debugger; the behaviors align with the reasoning above.


Why Other Options Are Wrong:

  • A/C/D include false statements 2 or 4, so they cannot be correct.


Common Pitfalls:
Assuming continue can send control into arbitrary labels or switch cases; misunderstanding that do executes once before the first test.


Final Answer:
1, 3, 5

More Questions from Control Instructions

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion