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
How can a gui component handle its own events in java programming?
Can final class have constructor?
How to overcome the exception object reference not set to an instance of object?
Explain treeset?
What is complexity and its types?
Implement a stack with push (), pop() and min() in O(1) time.
Can we catch more than one exception in a single catch block?
What is the purpose of using bufferedinputstream and bufferedoutputstream classes?
Explain the difference between an object-oriented programming language and object-based programming language?
How many types of operators are there?
What do you mean by formatting?
What is a function in java?
Define jre i.e. Java runtime environment?
What is an empty list in java?
Differentiate between nested and inner class in java.