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

Which access specifier can be used with class ?

0 Answers  


What does += mean coding?

0 Answers  


Can we create more than one object singleton class?

0 Answers  


what is difference between length and length()?

8 Answers  


What if constructor is protected in java?

0 Answers  






What is the synonym of framework?

0 Answers  


What is java regex?

0 Answers  


What is getclass () getname () in java?

0 Answers  


what is difference between throw and throws in exception?

48 Answers   Spenco,


Why string is not a wrapper class?

0 Answers  


Which is the best approach for creating thread ?

0 Answers  


Why do we need wrapper class?

0 Answers  


Categories