1 / 11

POLIMORFISME

POLIMORFISME. GALIH WASIS WICAKSONO. PREVIEW. Inheritance lets you guarantee that all classes grouped under a certain supertype have all the methods that the supertype has.

wiley
Télécharger la présentation

POLIMORFISME

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. POLIMORFISME GALIH WASIS WICAKSONO

  2. PREVIEW • Inheritance lets you guarantee that all classes grouped under a certain supertypehave all the methods that the supertype has. • When we say any Animal, we mean Animal and any class that extends from Animal. Which again means, any class that has Animal somewhere above it in the inheritance hierarchy

  3. POLIMORFISME • Polymorphism allows you to make changes in the method definition for the derived classes and have those changes apply to the software written in the base class. • The terms polymorphism and late binding are essentially just different words for the same concept. The term polymorphism refers to the processes of assigning multiple meanings to the same method name using late binding

  4. OVERRIDING • The arguments and return types of your overriding method must look to the outside world exactly like the overridden method in the superclass. • Rules of overriding : • Arguments must be the same, and return types must be compatible. • The method can’t be less accessible.

  5. CONT’D • You can mark a method to indicate that it cannot be overridden with a new definition in a derived class. You do this by adding the final modifier to the method heading. • Modifier final that definition the class, indicates that the class may not be used as a base class to derive other classes

  6. OVERLOADING • Method overloading is nothing more than having two methods with the same name but different argument lists. • Overloading lets you make multiple versions of a method, with different argument lists, for convenience to the callers. • Since an overloading method isn’t trying to fulfill the polymorphism contract defined by its superclass, overloaded methods have much more flexibility

  7. CONT’D

  8. CONT’D • Rules of overloading : • The return types can be different. • You can’t change ONLY the return type. • You can vary the access levels in any direction.

More Related