CodePudding user response:
Demonstrate the inheritance, Cupboard is not defined storage () method, why can call? Because of the inherited Chest, Chest with this method, so to subclassing also with this method, and then you can subclass the calling,CodePudding user response:
That is an example of a polymorphicSubclasses override the parent class method (the parent class is abstract method), thus changing the behavior of the method (such as storage and c w storage though are inherited abstract methods of the parent, but because the override the methods of treatment, so the behavior is different, w print is chest, c printing is cabinets)