Today's Question:  What weekend projects have you created?        GIVE A SHOUT

Technical Article => Programming =>  Programming

Polymorphism in OOP programming

  Pi Ke      2014-10-23 08:11:50      7,618    0

Polymorphism is the capability of an action or method to do different things based on the object that it is acting upon. This is the third basic principle of object oriented programming. Overloadingoverriding and dynamic method binding are three types of polymorphism.

Overloaded methods are methods with the same name signature but either a different number of parameters or different types in the parameter list. For example 'spinning' a number may mean increase it, 'spinning' an image may mean rotate it by 90 degrees. By defining a method for handling each type of parameter you control the desired effect.

Overridden methods are methods that are redefined within an inherited or subclass. They have the same signature and the subclass definition is used.

Dynamic (or late) method binding is the ability of a program to resolve references to subclass methods at runtime. As an example assume that three subclasses (Cow, Dog and Snake) have been created based on the Animal abstract class, each having their own speak() method. Although each method reference is to an Animal (but no animal objects exist), the program is will resolve the correct method reference at runtime.




Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr    Delicious



No comment for this article.


What an embarrassment

By sonic0002
When someone wants to hire someone with 7-10 years NodeJS experience, the NodeJS author jumped out and said that he had just 7 years experience of NodeJS because NodeJS was created in 2009, which is 7 years ago. What an embarrassment for the recruiter.