Which rules are valid for the sub constructor?
Class super has subclass sub.
Which rules are valid for the sub constructor? Note: There are 2 correct answers to this question.
A . The method signature can be changed.
B . Import parameters can only be evaluated after calling the constructor of super.
C . The constructor of super must be called before using any components of your own instance.
D . Events of your own instance cannot be raised before the registration of a handler in super.
Answer: AC
Explanation:
The sub constructor is the instance constructor of the subclass sub that inherits from the superclass super. The sub constructor has some rules that it must follow when it is defined and implemented12.
Some of the valid rules are:
The method signature can be changed: This is true. The sub constructor can have a different method signature than the super constructor, which means that it can have different input parameters, output parameters, or exceptions. However, the sub constructor must still call the super constructor with appropriate actual parameters that match its interface12.
The constructor of super must be called before using any components of your own instance: This is true. The sub constructor must ensure that the super constructor is called explicitly using super->constructor before accessing any instance components of its own class, such as attributes or methods. This is because the super constructor initializes the inherited components of the subclass and sets the self-reference me-> to the current instance12. You cannot do any of the following:
Import parameters can only be evaluated after calling the constructor of super: This is false. The sub constructor can evaluate its own import parameters before calling the constructor of super, as long as it does not access any instance components of its own class. For example, the sub constructor can use its import parameters to calculate some values or check some conditions that are needed for calling the super constructor12.
Events of your own instance cannot be raised before the registration of a handler in super: This is false. The sub constructor can raise events of its own instance before calling the constructor of super, as long as it does not access any instance components of its own class. For example, the sub constructor can raise an event to notify the consumers of the subclass about some status or error that occurred during the initialization of the subclass12.
Reference: 1: Inheritance and Constructors – ABAP Keyword Documentation – SAP Online
Help 2: Using Static and Instance constructor methods | SAP Blogs
Latest C_ABAPD_2309 Dumps Valid Version with 80 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund