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
What is pre increment and post increment in java?
What is void in java?
Can you instantiate the math class in Java?
What is the use of http-tunneling in rmi?
what is function overloading in java?
How many static init can you have?
What is the difference between a checked and an unchecked exception?
what is interface in java? Explain
What is vector?
What is the difference between scrollbar and scrollpane?
What is get () in java?
What happens if I remove static from main method?
Why stringbuilder is not thread safe?
Explain the hierarchy of java exception classes?
What is a string what operation can be performed out with the help of a string?