Method of a parent class, used from its subclass, uses attributes of the parent class only, if the method is not re-defined in subclass.
As long as a method (using private attributes) inherited from a superclass is not redefined, it still uses the private attributes of the superclass, not those of the subclass, even if the subclass has private attributes of the same name.
Class C1 contains a method M1 in the public section and a private variable, NUM of value = 5. Method M1 in class C1 displays the value of private variable, NUM.
Class C2 is a subclass of class C1. It does not redefine method M1. But, it has also a private variable , NUM with value = 6.
An object is created from class C2 and the method M1 is called.
The output shows that the variable NUM( as displayed by method M1) has been taken from class C1, not C2.
This establishes the theme.
CLASS c1 DEFINITION.
METHODS : m1.
DATA : num TYPE i VALUE 5.
CLASS c1 IMPLEMENTATION.
METHOD : m1.
CLASS c2 DEFINITION INHERITING FROM c1.
DATA : num TYPE i VALUE 6.
CLASS c2 IMPLEMENTATION.
DATA : oref2 TYPE REF TO c2.
CREATE OBJECT : oref2.
CALL METHOD oref2->m1.