Difficulty: Easy
Correct Answer: Only once.
Explanation:
Introduction / Context:
A constructor initializes a new object immediately after memory is allocated. The semantics guarantee predictable, one-time setup for that instance.
Given Data / Assumptions:
new
, which allocates memory and then calls the constructor.
Concept / Approach:
The constructor executes exactly once per instance, at construction time. You cannot re-run the constructor on an already created object. Re-initialization requires a separate method or creating a new instance.
Step-by-Step Solution:
Verification / Alternative check:
Experiment by trying to call the constructor like an ordinary method on an existing instance; this is not allowed.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming a constructor can serve as a reset method; write an explicit Reset()
if needed.
Final Answer:
Only once.
Discussion & Comments