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 an example of a boolean?
How do you pass by reference?
What is a boolean output?
difference between byte stream class and character stream class?
What is the difference between variable & constant?
How we can execute any code even before main method?
How can you traverse a linked list in java?
What is jit and its use?
What is dot operator?
How can a gui component handle its own events in java programming?
What is nested class?
What is the difference between variable declaration and variable initialization?
What is method overloading and method overriding?
How is it possible in java programming for two string objects with identical values not to be equal under the == operator?
What is the difference between the ">>" and " >>>" operators in java?