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

How can a gui component handle its own events in java programming?

632


Can final class have constructor?

592


How to overcome the exception object reference not set to an instance of object?

724


Explain treeset?

679


What is complexity and its types?

625






Implement a stack with push (), pop() and min() in O(1) time.

717


Can we catch more than one exception in a single catch block?

709


What is the purpose of using bufferedinputstream and bufferedoutputstream classes?

665


Explain the difference between an object-oriented programming language and object-based programming language?

635


How many types of operators are there?

620


What do you mean by formatting?

630


What is a function in java?

659


Define jre i.e. Java runtime environment?

658


What is an empty list in java?

626


Differentiate between nested and inner class in java.

653