REPORT ZCL_OOPS_TEST.
CLASS zcl_oops_abstract DEFINITION ABSTRACT.
PUBLIC SECTION.
METHODS: display_abstract ABSTRACT. "" Abstract class can have atleast one abstract method....
METHODS: display.
ENDCLASS.
CLASS zcl_oops_abstract IMPLEMENTATION.
METHOD display. "" Normal methods can be implemented here...
WRITE:/ 'Super-Class Method' .
ENDMETHOD.
""""" Abstract Method can not be implemented here.....
ENDCLASS.
CLASS zcl_oops_sub DEFINITION INHERITING FROM zcl_oops_abstract.
PUBLIC SECTION.
METHODS: display_abstract REDEFINITION. "" Abstract method can only be implemented afer redefinition by sub-class.
METHODS display_sub.
ENDCLASS.
CLASS zcl_oops_sub IMPLEMENTATION.
METHOD display_abstract. "" Abstract method can only be implemented in sub-class of abstract super-class.
WRITE:/ 'Abstract method(Inherited from abstract super class)'.
ENDMETHOD.
METHOD display_sub.
WRITE:/ 'Sub-Class method'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA : l_ref TYPE REF TO zcl_oops_sub.
CREATE OBJECT l_ref.
l_ref->display( ).
l_ref->display_abstract( ).
l_ref->display_sub( ).
Output
No comments:
Post a Comment