Why Over riding is Run Time Polymorphism?
Answer Posted / umanath
This is (Run Time Polymorphism) called Dynamic binding.
for more depth see the bellow example
class A
{
public String msg = "message-A";
public void display()
{
System.out.println(msg);
}
}
class B extends A
{
public String msg = "message-B";
public void display()
{
System.out.println(msg);
}
}
class demo
{
public static void main(String as[])
{
A a = new B() //RUN TIME POLYMORFISM
a.display() //Since a is a object type of class B SO class
B sum
System.out.println("From Main: "+a.msg);
}
}
Out Put:
message-B
From Main: message-A
| Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
Is string thread safe in java?
Define an abstract class with reference to java.
What are the supported platforms by java programming language?
What is native code?
What is the static field modifier?
Give differences between Quicksort & Mergesort. When should these sorts be used and what is their running time?
can any body body expalin best definitions & best real time exaples for opps concepts.
What are the data types supported by java?
Does anyone still use java?
What is the difference between == and === javascript?
Can constructor be protected in java?
What is the final class?
When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?
How we can make copy of a java object?
Why do we declare a class static?