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 a boolean field?
What is this keyword in java?
Is multiple inheritance supported by java?
What is length in java?
Why for each loop is used?
What is a function in java?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?
How to sort an unsorted array in java?
How many bits is a string?
What is numeric function?
What are the different http methods?
what is the difference between process and thread? : Java thread
Write a program to print count of empty strings in java 8?
What is a constructor, constructor overloading in java?
How can I become a good programmer?