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 type of value does sizeof return?
What is java and its types?
What initialize variables?
How do you check if a character in a string is a digit or letter?
What are inbuilt functions in java?
Write a program to find the whether a number is an Armstrong number or not?
Is integer a class?
When do I need to use reflection feature in java?
How is a structure different from array ?
What is the purpose of the system class in java?
How do you sort in ascending order in java?
explain multi-threading in java?
What is field name?
What is a class in java?
What are parameters in a method?