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 string args [] in java?
How to solve the problem of generating the unique hash keys with hash function?
What is an association?
What is the significance of continue jump statement? Explain with an example.
What is use of functional interface in java 8? Explain
Can we force the garbage collection to run?
Which collections are thread safe in java?
Can a final variable be manipulated in java?
What’s the difference between callable and runnable?
Can we have static methods in an interface?
Why is java called the platform independent programming language?
Define linked list and its features with signature?
how to handle exceptions in ejb?
Why do we need singleton?
What are the important features of Java 8 release?