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 a boolean output?
What is the difference between the boolean & operator and the && operator in java programming?
What is the purpose of using javap?
Can you extend singleton class?
What programs use java?
What is an immutable class?
What are use cases?
What do you mean by platform independence?
Can we create a constructor in abstract class?
When will you define a method as static?
What is substring 1 in java?
What is == and === in javascript?
What is a variable declaration?
Is void a wrapper class?
How will you communicate between two applets?