what is polymorphism?

Answers were Sorted based on User's Feedback



what is polymorphism?..

Answer / ganesh

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 achieve the effect that you want.

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

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. Overloading and overriding are two types of
polymorphism . Now we will look at the third type: dynamic
method binding.

Assume that three subclasses (Cow, Dog and Snake) have been
created based on the Animal abstract class, each having
their own speak() method.

Example:
--------
public class AnimalReference
{
public static void main(String args[])
Animal ref // set up var for an Animal
Cow aCow = new Cow("Bossy"); // makes specific objects
Dog aDog = new Dog("Rover");
Snake aSnake = new Snake("Earnie");

// now reference each as an Animal
ref = aCow;
ref.speak();
ref = aDog;
ref.speak();
ref = aSnake;
ref.speak();
}
Notice that although each method reference was to an Animal
(but no animal objects exist), the program is able to
resolve the correct method related to the subclass object
at runtime. This is known as dynamic (or late) method
binding.

Is This Answer Correct ?    16 Yes 2 No

what is polymorphism?..

Answer / navieen

Polymorphism means the ability of a single variable of a
given type to be used to reference objects of
different types, and automatically call the method that is
specific to the type of object the variable references.
The benefit of polymorphism is that it is very easy to add
new classes of derived objects without breaking the calling
code that uses the polymorphic classes or interfaces.
When you send a message to an object even though you
don’t know what specific type it is, and the right thing
happens, that’s called polymorphism. The process used by
object-oriented programming languages to implement
polymorphism is called dynamic binding.

Is This Answer Correct ?    10 Yes 2 No

what is polymorphism?..

Answer / sumalatha

HI,
POLYMORPHISM is very good fature...in oops mainly
polymorphism means manyforms..that is by using polymorphism
with the same name signature
but either a different number of parameters or different
types in the parameter list..it is colled methodover
loading.Another one is Overridding...it is also very usful
for us..by using this u can use in Baseclass and
DerivedClass same mathodname..with diffarent body is
possibul..but we use override keyword

Is This Answer Correct ?    4 Yes 0 No

what is polymorphism?..

Answer / srikanth jakka

Polymorphism is a feature that allows one interface to be
used for a general class of actions.
The specific action is determined by the exact nature of
the situation.

Is This Answer Correct ?    3 Yes 0 No

what is polymorphism?..

Answer / kartheeswari

Allows many methods with same name and with different
argument list, order,type to do the closely related task.

Is This Answer Correct ?    4 Yes 4 No

Post New Answer

More Core Java Interview Questions

What is java thread dump, how can we get java thread dump of a program?

0 Answers  


What is the current version of java?

0 Answers  


What is the range of the char type?

3 Answers  


Is set ordered?

0 Answers  


Is overriding possible in java?

0 Answers  






what is the difference between future and callable interface in java?

0 Answers  


If you are given the name of the function at run time how will you invoke the function?

0 Answers   Adobe, Yahoo,


what are variables in java

7 Answers   Wipro,


What is an event?

2 Answers  


explain the life cycle of thread?

10 Answers   CTS, NIIT, TCS,


Which is better 64 bit or 32 bit?

0 Answers  


How do you trim a space in java?

0 Answers  


Categories