Advanced
Object-Oriented Programming Concepts
Q93 / 100
What subtle issue can arise from calling an overridable (virtual) method from within a constructor?
Correct! Well done.
Incorrect.
The correct answer is A) The overridden version in a subclass may execute before the subclass's own fields have been initialized, leading to unexpected state
A
Correct Answer
The overridden version in a subclass may execute before the subclass's own fields have been initialized, leading to unexpected state
Explanation
During base class construction, if a virtual method is called and overridden by a subclass, the subclass override may run against partially-initialized subclass state, a well-known pitfall in many OOP languages.
Progress
93/100