Need to check and comment some lines of code in the program, because
for understanding I have written all the possibilities………
REPORT zcl_oops_test.
CLASS cl_final DEFINITION FINAL. "Can not be inherited....
**** methods can not be inherited of final class - while defining inside final class it becomes final method automatically.....
PUBLIC SECTION.
METHODS: name.
ENDCLASS.
class cl_final definition.
PUBLIC SECTION.
methods: name FINAL. "Can not be inherited...
methods: details. "Can be inherited.....
ENDCLASS.
CLASS cl_final IMPLEMENTATION.
method name.
write:/ 'Final Method'.
ENDMETHOD.
method details.
write:/ 'Another Method of Super Class'.
ENDMETHOD.
ENDCLASS.
*
CLASS cl_inherit DEFINITION INHERITING FROM cl_final.
PUBLIC SECTION.
methods: name REDEFINITION. ""Can not be redefined...
METHODs: details REDEFINITION. ""Can be redefined...
ENDCLASS.
class cl_inherit IMPLEMENTATION.
method name.
write:/ 'Inherited Class'.
ENDMETHOD.
method details.
write:/ 'Another Method of Sub Class'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
data: obj1 type REF TO cl_final,
obj2 type REF TO cl_inherit.
create OBJECT: obj1,
obj2.
call method obj1->name.
call method obj2->name.
call method obj1->details.
call method obj2->details.
No comments:
Post a Comment