Difficulty: Easy
Correct Answer: 2) Constructors always share the class name. 3) Constructors are never called explicitly. 4) Constructors never return any value.
Explanation:
Introduction / Context:Constructors define how objects are initialized. Several myths persist about their capabilities and responsibilities.
Given Data / Assumptions:
Concept / Approach:In C#, a constructor's name matches the class name, it does not return a value (no return type), and it is not called like a normal method by user code; rather, it runs automatically during new or is chained via this(...) / base(...). Memory allocation is performed by the runtime before the constructor runs; the constructor initializes the already allocated object.
Step-by-Step Solution:
Statement 1: False — constructors can be overloaded.Statement 2: True — name equals class name.Statement 3: True — invoked by construction/chaining, not as an ordinary call.Statement 4: True — constructors have no return type.Statement 5: False — allocation precedes constructor execution; constructors do not allocate.Verification / Alternative check:Check the C# spec and observe that adding different parameter lists is legal and that constructors have no return type.
Why Other Options Are Wrong:
Common Pitfalls:Attributing memory allocation to constructors rather than to the runtime allocator.
Final Answer:2, 3, 4
Discussion & Comments