C#.NET — Which statement about constructors is correct?

Difficulty: Easy

Correct Answer: A constructor can be a static constructor.

Explanation:


Introduction / Context:
Constructors in C#.NET initialize objects and set up type-level state. In addition to ordinary instance constructors, the language also supports a special kind called a static constructor, which runs once per type to initialize static members.



Given Data / Assumptions:

  • The question compares several claims about what constructors can and cannot do.
  • We must choose the single correct statement among common misconceptions.


Concept / Approach:
There are two broad constructor categories in C#: instance constructors (can be overloaded, can be private/protected/internal/public) and static constructors (no parameters, no access modifiers, run automatically once, and initialize static data). An instance constructor executes with an implicit this reference and can read/write both instance and static members. Static constructors have no this and can touch only static state.



Step-by-Step Solution:

Check A: False — instance constructors may be private (singletons/factory patterns).Check B: False — constructors can be overloaded by parameter lists.Check C: True — static constructors are valid and common for type initialization.Check D: False — instance constructors can access static data.Check E: False — instance constructors do receive this; it refers to the object under construction.


Verification / Alternative check:
Compile a class with a private constructor (compiles) and with multiple overloads (compiles). Add a static constructor to set static fields (compiles and runs once at first use).



Why Other Options Are Wrong:

  • A: Private constructors are legal and commonly used.
  • B: Overloading is fully supported.
  • D: Instance constructors can set static fields.
  • E: this exists in instance constructors; only static constructors lack it.


Common Pitfalls:
Confusing static constructors (type initialization) with instance constructors (object initialization).



Final Answer:
A constructor can be a static constructor.

Discussion & Comments

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