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
Give few difference between constructor and method?
Is null or empty java?
Can variables be used in java without initialization?
What are the three parts of a lambda expression?
How to restrict a member of a class from inheriting by its sub classes?
What is the symbol for space?
What is length in java?
Write a java program to generate fibonacci series ?
What is a singleton in genetics?
How are the elements of a gridbaglayout organized in java programming?
What is stringbuffer in java?
Can we create a class inside a class in java?
Which java collection does not allow null?
Differentiate between array list and vector in java.
Differentiate between static and non-static methods in java.