Object Oriented ABAP
Object Oriented ABAP
Object Oriented ABAP
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
We can not invoke the new method defined in the class b xyz() using base class obj_a<br />
reference variable.<br />
obj_a = obj_b.<br />
call method : obj_a->xyz. Is not possible. It will throw an error.<br />
In this case we can only call<br />
call method : obj_a->fall,<br />
obj_a->rise.<br />
When we call obj_a->fall , it will call the method of base class since it is not redefined in<br />
sub class b.<br />
When we call obj_a->rise, it will call the method of sub class since it is redefined in sub<br />
class b. For this we can use the table of section 2.3.<br />
2.5 Output of section 2.1<br />
We can now verify the output of code given in section 2.1 from the table described in<br />
section 2.3<br />
We will just see the START-OF-SELECTION and END-OF-SELECTION events below from<br />
section 2.1<br />
******************************************************************<br />
* START-OF-SELECTION<br />
*******************************************************************<br />
START-OF-SELECTION.<br />
create object : obj_a,<br />
obj_b1,<br />
obj_b2.<br />
******************************************************************<br />
* END-OF-SELECTION<br />
*******************************************************************<br />
END-OF-SELECTION.<br />
call method : obj_a->fall,<br />
obj_a->rise,<br />
obj_b1->fall.<br />
Now output of above code is :<br />
Super class a-----------fall()<br />
Super class a-----------rise()<br />
Super class a-----------fall()<br />
Here obj_a refers to base class object so it only calls base class methods rise() and fall().<br />
Since method fall() is not redefined in class b and is just inherited from class a , so when<br />
we call obj_b1->fall, the base class method is invoked.