Home > Software > Java > Core-Java
Interview Questions   Tutorials   Discussions   Programs   

Core-Java - What is polymorphism with example? types of polymorphism?

asked marvit September 16, 2014 11:19 PM  

What is polymorphism with example? types of polymorphism?


1 Answers

answered By Madhumathi   0  

Polymorphism is the ability of an object to take on many forms. There are two types of polymorphism in java- Runtime polymorhism ( Dynamic polymorphism) and Compile time polymorphism (static polymorphism).

Method overriding is a perfect example of runtime polymorphism. Since in method overriding both the classes(base class and child class) have same method, compile doesn’t figure out which method to call at compile-time. In this case JVM(java virtual machine) decides which method to call at runtime that’s why it is known as runtime or dynamic polymorphism.

Compile time polymorphism is nothing but the method overloading in java.In simple terms we can say that a class can have more than one methods with same name but with different number of arguments or different types of arguments or both.

   add comment

Your answer

Join with account you already have



Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!