Explain the Polymorphism principle.

The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as as general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as "one interface, multiple methods". 

Showing Answers 1 - 34 of 34 Answers

Paul

  • Aug 4th, 2005
 

Polymorphism 
 
This ability of different objects to respond, each in its own way, to identical messages is called polymorphism. 
Polymorphism results from the fact that every class lives in its own name space. The names assigned within a class definition won't conflict with names assigned anywhere outside it. This is true both of the instance variables in an object's data structure and of the object's methods: 
 
 
Just as the fields of a C structure are in a protected name space, so are an object's instance variables.  
 
Method names are also protected. Unlike the names of C functions, method names aren't global symbols. The name of a method in one class can't conflict with method names in other classes; two very different classes could implement identically named methods.  
 
Method names are part of an object's interface. When a message is sent requesting an object to do something, the message names the method the object should perform. Because different objects can have different methods with the same name, the meaning of a message must be understood relative to the particular object that receives the message. The same message sent to two different objects could invoke two different methods. 
 
The main benefit of polymorphism is that it simplifies the programming interface. It permits conventions to be established that can be reused in class after class. Instead of inventing a new name for each new function you add to a program, the same names can be reused. The programming interface can be described as a set of abstract behaviors, quite apart from the classes that implement them.

pinak

  • Sep 27th, 2005
 

polymorohism is like to have one form with many use.A singal operator can be use in diffent forms but thire meaning remains same.

  Was this answer useful?  Yes

siba narayan patro

  • Oct 20th, 2005
 

Numerous forms of a single object is called polymorphism. Numerous means more than one.

  Was this answer useful?  Yes

kiran

  • Nov 10th, 2005
 

prolymorphism is the concept of using single entity in many ways according to the users request in the programing structure,Multiple methods are entertained from single category is the nature of the polymorphism.

  Was this answer useful?  Yes

gayatri

  • Nov 18th, 2005
 

polymor.  means when an object perform various function. for example your mobile phone u can connect to internet ,u may communicate  to ur frnds  n may other function u can perform through  one object<ur mobile phone>

  Was this answer useful?  Yes

Ashish

  • Nov 21st, 2005
 

The polymorphism is a "Single interface and multiple method". for example : x is a person and he works different so x is a single interface and its works multiple interface

  Was this answer useful?  Yes

Anjan

  • Nov 30th, 2005
 

Excellent explanation !!

  Was this answer useful?  Yes

Rahul Dhadphale

  • Dec 1st, 2005
 

Ploymorphism is a process where 2 diff. functions with the same name,passing diff. argument list. it meaning is that you can use same function name for diff. porpuse.

  Was this answer useful?  Yes

: The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as as general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as "one interface, multiple methods".

  Was this answer useful?  Yes

anshul sood

  • Apr 17th, 2006
 

polymorphisnm is a principal used to implement overriding,it is same signature with diffrent tasks.

  Was this answer useful?  Yes

Polymorphism in OOP languages, for example take Java, is attained by using its features: Overriding and Overloading methods.

Overriding: When Class B extends Class A, Class B can override method1 in Class A. Class B must have same method name AND (different parameter types OR no. of parameters differ to orginal method) AND must have same return type as of Class A.

Overloading: Overloading happens in the same class. It can have same method name AND (different parameter types OR no. of parameters differ to orginal method) OR may have different return type.

The method to call is selected at run-time. Therefore it is called late-binding.

  Was this answer useful?  Yes

Virender Sundriyal

  • Jun 2nd, 2006
 

One Interface Multiple implementation.

Like an abstract class.

  Was this answer useful?  Yes

vijay

  • Jun 22nd, 2006
 

means the abilty to take more than one form. an operation may exibit different behavoiurs in different instances. it depends on the data types used in the operation

  Was this answer useful?  Yes

sumeshcs

  • Jun 26th, 2006
 

Source:http://www.webopedia.com/TERM/P/polymorphism.html Generally, the ability to appear in many forms. In object-oriented programming, polymorphism refers to a programming language's ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes. For example, given a base class shape, polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct results. Polymorphism is considered to be a requirement of any true object-oriented programming language (OOPL).

  Was this answer useful?  Yes

Shariq Maqbool Khan

  • Jan 11th, 2007
 

Excellent and self explanatory :)

Rgds,

Shariq

  Was this answer useful?  Yes

PritiDarsini

  • Feb 9th, 2007
 

Polymorphism means one function can be used differently in differenent situations.

  Was this answer useful?  Yes

satheesh kumar

  • Apr 6th, 2007
 

  • it is nothing but taking many forms from  a single form.

  Was this answer useful?  Yes

Lakshmi

  • Sep 9th, 2007
 

Polymorphism deals with how messages are exchanged between objects. How each object responds in many ways to the same or different message.

  Was this answer useful?  Yes

Rad

  • Oct 14th, 2007
 

Polymorphism consists of 2 principles: Overloading and Overriding

  Was this answer useful?  Yes

msuresh70

  • May 25th, 2009
 

Polymorphisam: It can be catagorized into three ways.

1. Method Overloading

2. Method Over-riding

3. Interface methods implemented differently in different ways in sub-classes.

Overloading: Define methods with same name , same return type with different parameters or with different datatypes or with different order of parameters.

Over-riding: Re-define method in the sub-class with same signature. One restriction is method modifier can't be more liberal than in parent class.  (i.e. private in parent class and public in sub-class).

Interface: Interface will be implemented by different classes in differet ways depending on the nature of the sub-class.  Eg: Car has enginetype() method. This method will get implemented differently for V6 Engine and V4 Engine. Though the method name remain same, its implementation will be different.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions