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
What is the use of coding?
How is garbage collection controlled?
What is the generic function?
What is the byte order of byte buffer?
Can we declare the main method of our class as private?
What is string in java?
Can a class be defined inside an interface?
What's the default access specifier for variables and methods of a class?
What are the important features of Java 11 release?
What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?
Difference between notify() method and notifyall() method in java?
What is factor r?
do I need to use synchronized on setvalue(int)? : Java thread
What does file separator do in java?
how are methods defined?