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.
obj_a = obj_b1.<br />
Then both obj_a and obj_b now refer to same object of class b.<br />
But obj_a is reference variable of type parent class of class b.<br />
Now when<br />
obj_a = obj_b .<br />
Reference variable is of type Base Class<br />
<strong>Object</strong> passed is of type Sub Class.<br />
When we will use the reference variable obj_a to invoke method rise() which is overridden<br />
in sub class b, the sub class b method rise() (redefined method) is invoked.<br />
So if we change the code below START-OF-SELECTION event and END-OF-SELECTION event<br />
in section 2.1 to check the above theory.<br />
*****************************************************************<br />
* START-OF-SELECTION<br />
******************************************************************<br />
START-OF-SELECTION.<br />
create object : obj_a,<br />
obj_b1,<br />
obj_b2.<br />
obj_a = obj_b1.<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 />
Child class b redefined-----------rise()<br />
Super class a-----------fall()