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 are the advantages of functions?
What is not thread safe?
Explain wrapper classes in java?
Explain about instanceof operator in java?
What are the two ways of implementing multi-threading in java?
What kind of variables can a class consist?
How do you stop a thread in java?
Why does java not allow multiple public classes in a java file ?
What is the instance of an object?
What is the function of log?
What is the applet security manager, and what does it provide?
Is it necessary for the port addresses to be unique? Explain with reason.
Explain thread life cycle in java?
Why parsing is done?
Explain about object oriented programming and its features?