cancel
Showing results for 
Search instead for 
Did you mean: 

OOABAP

128
Explorer
282

Hello everyone, please help me with the following question:

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 the program created an instance of sub1. In which sequence will the constructors be executed?

a. Class constructor of super1

b. Instance constructor of sub1

c. Instance constructor of super 1

d. Class constructor of sub1.

Sandra_Rossi
Active Contributor

Nice interview question. What do you think?

View Entire Topic
Sijin_Chandran
Active Contributor

Hello,

The right sequence is:

1.) Static Constructor of super1.

2.) Static Constructor of sub1.

3.) Instance Constructor of sub1

4.) Instance Constructor of super1 finally!

Refer the below SAP link for better understanding,

https://learning.sap.com/learning-journeys/acquire-core-abap-skills/implementing-inheritance_bfdb59f...

Thanks,

Sijin

Sandra_Rossi
Active Contributor
0 Kudos

Aligned to the OP question, the exact answer would be {a, d, b, c} :

a. Class constructor of super1

d. Class constructor of sub1.

b. Instance constructor of sub1

c. Instance constructor of super 1

 

Sijin_Chandran
Active Contributor
0 Kudos
Yeah with 'Static Constructor' I meant CLASS_CONSTRUCTOR only, just aligned the name as per Standard SAP document 🙂