Home > Back-end >  Application of polymorphic
Application of polymorphic

Time:10-06

A friend write a master class, writing class (with an abstract method - say "hello" sayHello), friends, there are two subclasses: Chinese friends and foreign friends different sayHello (implementation), one of the master class, Serving methods used for such services for all kinds of friends, friends for its parameter of object references, but into the class participation for Chinese friend or foreign friends of object references, the method of all his friends who meet to greeting master class sayHello, then the owner will provide different services for different countries friends (different services such as the language of communication, the choice of food, etc.), write a test class, testing the parent parameter and subclass into polymorphism,
  • Related