You have a superclass super1 and a subclass sub1 of super1. Each class has an instance constructor and a static constructor. The first statement of your program creates an instance of sub1.
In which sequence will the constructors be executed?
Execution order when creating an instance of a subclass:
Class constructor of the superclass (super1) executes first.
Class constructor of the subclass (sub1) executes second.
Then the instance constructor of the superclass (super1) executes.
Finally, the instance constructor of the subclass (sub1) executes.
This sequence guarantees that both the static (class-level) and instance-level initializations of the superclass are complete before the subclass is constructed.
Verified Study Guide Reference: ABAP Objects Programming Guide -- Class and Instance Constructor Execution Order.
Currently there are no comments in this discussion, be the first to comment!