In SAP ABAP inheritance is considered as one of the main concepts in object oriented programming. Inheritance describes the relationship between two classes. i.e class within the class. It helps to create and maintain an application easily. This also gives an opportunity to reuse the code functionality and implementation method.
In ABAP inheritance is involved with two classes, i.e parent class and sub class. So when the user creates a class, the subclass inherits the data from the parent class. This prevents the programmer to include the data details again and again. Instead of doing that, the data can be directly taken from the existing class.
The inheritance relationship is specified using the ‘INHERITING FROM’ addition to the class definition statement.
Following is the syntax −
The above code displays the following output −
A super class or parent class has the capacity to access all the non-private members of its sub class. Due to the encapsulation of restricted data, the private members of the super class cannot be accessible to the member functions of sub classes. You can see below in the tabular form of different data types which is used by the users are-
The derived super class inherits its members through public, protected or private inheritance. The type of inheritance is determined by the access specifier as explained above. Rarely, the user uses the protected or private inheritance, but the most widely used is public inheritance. The following rules are applied while using different types of inheritance.
The methods of the super class can be re-implemented in the sub class. Few rules of redefining methods −
After executing F8, if we enter the values 9 and 10, the above code produces the following output −
SAP ABAP Related Interview Questions
|SAP CRM Interview Questions||SAP BI Interview Questions|
|SAP MM Interview Questions||SAP BASIS Interview Questions|
|SAP ABAP Web Dynpro Interview Questions||SAP Workflow Interview Questions|
|Sap Abap Hr Interview Questions||SAP ABAP Dictionary Interview Questions|
|SAP ABAP Enhancement Interview Questions||SAP ABAP Module Pool Interview Questions|
|SAP ABAP Report Developer Interview Questions||SAP ABAP Data Dictionary Interview Questions|
|SAP ABAP ALV Reports Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.