what is run time polymorphism

Answer Posted / vijayakumar chinnasamy

In Java Method overriding is the runtime or late binding
polymorphism.

class object is determine which class method is invoked.

ex:

class A {
protected void display(){ }

}

class B extends A {

protected void display(){ }

}

class MainClass {
public static void main(String arg[]){

A objA=null;
objA=new B();
objA.display(); // it invoke the Class B's display()

objA=new A();
objA.display(); // it invoke the Class A's display()

}

}

Note: the class's object only determine which method to call.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you need to import math in java?

565


What is a parameter example?

531


What is the static block?

585


How will you communicate between two applets?

632


What mechanism does java use for memory management?

494






How do you write a scanner class in java?

570


How can constructor chaining be done by using the super keyword?

622


What are the three best choices for a development environment?

609


Which is better 64 bit or 32 bit?

511


How we can run a jar file through command prompt in java?

524


How are multiple inheritances done in Java?

622


Explain the key functions of data binding?

585


What is the basic of java?

573


What is the difference between Array and Hash Table?

547


Does java vector allow null?

544