REPORT YSUBOOPS18.
class c1 definition.
public section.
methods : m1.
endclass.
class c1 implementation.
method m1 .
write:/5 ' I am m1 of c1'.
endmethod.
endclass.
class c2 definition inheriting from c1.
public section.
methods : m1 redefinition.
endclass.
class c2 implementation.
method m1.
write:/5 'I am m1 of c2'.
endmethod.
endclass.
START-OF-SELECTION.
DATA : OREF1 TYPE REF TO C1,
OREF11 TYPE REF TO C1,
OREF111 TYPE REF TO C1,
OREF2 TYPE REF TO C2 .
CREATE OBJECT : OREF1 ,
OREF11 TYPE C2,
OREF111 ,
OREF2 .
OREF111 = OREF2.
CALL METHOD : OREF1->M1 , “ Output : I am m1 of c1
OREF11->M1 , “ Output : I am m1 of c2
OREF111->M1, “ Output : I am m1 of c2
OREF2->M1 . “ Output : I am m1 of c2
Output
I am m1 of c1
I am m1 of c2
I am m1 of c2
I am m1 of c2
No comments:
Post a Comment