Mentor SAP
2017-05-01 Submitted by:- Admin

The program used here is similar to above with change in the method : subval of class : childclass . This method is now attempting to access the attribute : privatedata , which is a private attribute of its superclass :
parentclass. On compilation, the program will give a compilation error. This demonstrates that private components of superclass cannot be accessed by subclasses.

Take the first program. Only change the method : subval of class : childclass as follows:-

method : subval.
skip 1.
write:/5 'All data from parent class shown by subclass'.
write:/5 sy-uline.
WRITE:/5 COMMONDATA,
/5 PROTECTDATA,
/5 privatedata.
endmethod.

The program will not compile. It will show an error message:-