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

What is garbage collection? Can it be forced to run?

545


What does opcode mean?

543


What is a stack class in java ?

614


Is array size fixed in java?

546


what is meant by Byte code concept in Java?

600






What is the purpose of the system class in java?

558


Why string is not thread safe?

545


What is t in generics in java?

565


How many decimal digits is 64 bit?

536


How can u increase the heap size in the memory?

558


What is an empirical question?

546


Why null value is used in string?

532


Why do people says “java is robust”?

566


Is overriding possible in java?

510


how to create multithreaded program? Explain different ways of using thread? : Java thread

538