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
If we don’t want some of the fields not to serialize how to do that?
What is the function of character?
What is loop in java?
Tell me the latest versions in java related areas?
When we should use serialization?
What is java in simple terms?
What is java and their uses?
explain local datetime api in java8?
What is a singleton class in Java?
What does flag mean in java?
Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?
What is diamond operator in java?
When does an object becomes eligible for garbage collection in java?
How do you read a char in java?
Can we pass null as argument in java?