Start networking and exchanging professional insights

Register now or log in to join your professional community.

Rehan Qureshi
by Rehan Qureshi , Financial Consultant , Self Employeed

Definition - What does Polymorphism mean?

Polymorphism is an object oriented programming concept to refer to the ability of a variable, function, or object to take on multiple forms. A language that features polymorphism allows developers to program in the general rather than program in the specific.

Techopedia explains Polymorphism

In a programming language that exhibits polymorphism, objects of classes belonging to the same hierarchical tree (i.e. inherit from a common base class) and may possess functions bearing the same name but each having different behaviors.

 

As an example, let us assume you have a base class named Animals from which the subclasses Horse, Fish and Bird are derived. Let us also assume that the Animals class has a function named Move, which is inherited by all subclasses mentioned. With polymorphism, each subclass may have its own way of implementing the function. So, for example, when the Move function is called in an object of the Horse class, the function might respond by displaying trotting on the screen. On the other hand, when the same function is called in an object of the Fish class, swimming might be displayed on the screen. In the case of a Bird object, it may be flying.

 

 

In effect, polymorphism trims down the work of the developer because he can now create a sort of general class with all the attributes and behaviors that he envisions for it. When the time comes for the developer to create more specific subclasses with certain unique attributes and behaviors, the developer can simply alter code in the specific portions where the behaviors will differ. All other portions of the code can be left as is.

Ahmad Anbari
by Ahmad Anbari , Software System Engineer , Continental Jet Services FZCO

It is simply: same interface multiple implementations. There are two different types of polymorphism: static and dynamic.

 

The static one is decided at the design time, and the dynamic one is decided at the run time.

 

To make it clear let’s take this example: We write a Shape class which has a print method. As we all know a rectangle, square, and a circle are all shapes. So, they all inherit from the Shape class. Each one of them implements the print function to reflect itself to the printing device. The Rectangle draw a rectangle, the circle draws a circle and so forth. Let say way are writing a painting application that keep all the objects on the drawing sheet in a list of shapes so we can print it later. At the time the user click the print button in the painting application, we will ask the list of shapes to print itself. The list will ask every object to print himself. Every shape will print the corresponding shape that reflects himself. This way the list only calls the print method, regardless this shape is a circle, a rectangle or a square. 

sreerag arimbrathodiyil
by sreerag arimbrathodiyil , Software Developer , SystechInfovations

Polymorphism is the ability to represent more than one form

there are two types of  representaions

1)Runtime polymorphism

ie Method overriding

2)Compile Time polymorphism

ie method overloading

polymorphism is a feature of oops where one interface is used for general class of action.

Azmat Jadoon
by Azmat Jadoon , Software Engineer , NADRA

In short, polymorphism is the change in behavior of an object at runtime.

Divya Dinesh Mittal Divya
by Divya Dinesh Mittal Divya , Program Analyst , Cognizant Technology Solutions

When same message is passed to different objects, each object responds differently depending upon its class. zthis is polymorphism.It is applied only to instance method and not to variables and static methids.

POLYMORPHISM--

BEHAVING IN DIFFERENT WAYS DEPENDING UPON INPUT RECIEVED IS KNOWN AS POLYMORPHISM.THAT IS WHENEVER INPUT CHANGES AUTOMATICALLY THE OUTPUT OR BEHAVIOUR ALSO CHANGES.

POLY MEANS- MANY

MORPHISM MEANS--FORMS

MANY FORMS OR ROLES PERFORMED BY SINGLE ENTITY IS POLYMORPHISM.

POLYMORPHISM CAN BE IMPLEMENTED IN OOP USING3 DIFFERENT APPROACH--

1.OVERLOADING

2.OVERRIDING

3.HIDING/SHADOWING

OVERLOADING IS AGIAN OF3 TYPES--

--METHOD OVERLOADING

--CONSTRUCTOR OVERLOADING

--OPERATOR OVERLOADING

 

Sandhya Binoy
by Sandhya Binoy , Software Professional , Karrox technologies

Polymorphism is one of Object Oriented Programming Concept.

Polymorphism is the abilty to take on many forms.Applied  both to objects and to operations.

One operation,Many methods.

Two types of polmorphism:

Static(compile time) polymorphism means that the information required to call,a function is available at compile time itself.It is achieved through function overloading,operator overloading and even function templates.

Dynamic(run time) polymorphism means that the information required to call a function is not known until run time.It is achieved through inheritance and virtual functions.

Eg:A plus '+' sign,used for adding two integers or for using it to concatenate two strings.

 

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.