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 modifiers may be used with a top-level class?

0 Answers  


What methodology can be utilized to link to a database?

0 Answers  


how to use finalize()Method to resources

4 Answers   TCS,


What are null interfaces? Give some examples?

2 Answers  


What is JVM ?

4 Answers   Phantom Technologies, TCS,






How can we access some class in another class in java?

0 Answers  


If an object reference is set to null, will the garbage collector immediately free the memory held by that object?

0 Answers  


Diff between Comparator and Comparable?

2 Answers   Aditya Birla,


What is a method type?

0 Answers  


What are "methods" and "fields"?

0 Answers   Wipro,


What do you mean by constructor?

0 Answers  


Is it possible to make an array volatile?

1 Answers  


Categories