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
When do we need to use internal iteration? When do we need to use external iteration?
What is percentage in java?
What is the same as procedures?
What exceptions occur during serialization?
Difference between string, string builder, and string buffer?
How do you invoke a method?
Can we force garbage collector to run ?
How is it possible for two string objects with identical values not to be equal under the == operator?
What is the meaning of nullable?
How does multithreading take place on a computer with a single cpu in java programming?
What is difference between variable declaration and definition?
What is your platform?s default character encoding and how to know this?
What are the special characters?
What are different types of expressions?
What is abstraction in java?