polymorphism in java

Polymorphism:
                                The polymorphism in java is an oops concept one method performing different operations is known polymorphism. In polymorphism same method performing different operations.

There are two types of polymorphisms in java
1.       Compile time polymorphism (static polymorphism)
2.       Run time polymorphism (Dynamic  polymorphism)

Compile time polymorphism:
                Compile time polymorphism is nothing but the method overloading in java. A class has more than one method with the same name but performing different operations and it has different arguments. The compile time polymorphism is also known static polymorphism.

Run time polymorphism:
                The reference of the super class can hold an object of the superclass or an object of its subclasses of the superclass. In java runtime polymorphism is also known as dynamic polymorphism.
In method overriding both the classes ( parent, child classes|) have same methods,  in this case, compile time JVM doesn’t figure out which method to call, but it decides at runtime.
Example: Method Overriding

Interview Questions:

What do you know about polymorphism ?
Explain about polymorphism ?
What is Compile time polymorphism?
What is runtime polymorphism ?
What are the difference between  compile time polymorphism and runtime polymorphism ? 


EmoticonEmoticon