Difficulty: Easy
Correct Answer: 2, 3, 5
Explanation:
Introduction / Context:
This item examines behavior and structure rules for void methods (often called “subroutines”) in C#: whether they can be nested, whether recursion is allowed, and how to exit early. It also checks the misconception of implicit return values from void methods.
Given Data / Assumptions:
Concept / Approach:
Void methods do not return values. Early exit is done with return; there is no “exit subroutine” keyword in C#. Standard teaching says method definitions are at type scope (no nested method definitions in typical C#), recursion is allowed, and calls can be nested within expressions or other calls as long as signatures permit.
Step-by-Step Solution:
Verification / Alternative check:
Compile short examples: a recursive void PrintList(Node n); a method that does early return; attempts to use “exit subroutine” fail to compile; nested method definitions are not part of traditional C# method declaration patterns.
Why Other Options Are Wrong:
Common Pitfalls:
Transferring VB syntax into C#, assuming void implies some numeric sentinel, or thinking recursion is limited to functions that return values.
Final Answer:
2, 3, 5
Discussion & Comments