What is run time polymorphism?

Answer Posted / guest

In Runtime polymorphism the JVM will decide which version
of the method supposed to used.

for example
class Animal{
public void speak(){
System.out.println("Animal speak method callinfg");
}
}

public class Dog extends Animal{
public void speak(){
System.out.println("Dog speak method calling");
}

public static void main(String args[]){

Animal a = new Dog();

a.speak();// u r calling now Animal class speck metod.
}
}
here JVM will decide to execute Dog version of speck
method . This is called runtime polimorphism

thanks
prasad thota

Is This Answer Correct ?    13 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What if I write static public void instead of public static void in java?

576


What are the disadvantages of using inner classes?

549


What is data type modifier?

527


What is a line separator in java?

533


What is a java applet? What is an interface?

627






Explain the public class modifier?

497


What is method overriding in java ?

650


What is the use of arrays tostring () in java?

512


Which class is used by server applications to obtain a port and listen for client requests?

491


What is unmodifiable collection in java?

505


What is the difference between method overriding and overloading?

571


Can you run java program without main method?

541


What does || mean in code?

543


What is java jit compilers?

556


Is null a string or object in java?

545