Definition: The methods of the super class can be re-implemented at the sub class.
Purpose to redefine methods: if the method implementation at the super class is not satisfies the requirement of the object which is created with reference to the sub class.
Principles of redefining methods:
- The REDEFINITION statement for the inherited method must be in the same SECTION as the definition of the original method.
- If you redefine a method, you do not need to enter its interface again in the subclass, but only the name of the method.
- In the case of redefined methods, changing the interface (overloading) is not permitted; exception: Overloading is possible with the constructor
- Within the redefined method, you can access components of the direct super class using the SUPER reference.
- The pseudo-reference super can only be used in redefined methods.
Demo program for redefining method:
Go to transaction SE38:
Give any name for the program.
After execution (F8):
Result:
Demo for use of super keyword in redefinition:
Go to transaction SE38.
After execution (F8):
Result:
No comments:
Post a Comment