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 constant variable?
What is purpose of applet programming?
How do I run java on windows?
What is a nullable field?
Explain about serializable interface in java?
How many return statement are allowed in a function?
What is string syntax?
Is array a class in java?
How do you implement polymorphism in our day to day life?
What is the default value of byte datatype in java?
Why convert an applet to an application?
What is == mean?
What is the purpose of nested class in java?
Addition to previous section relative word 5th one was Putrid ans: rotten, also there was prob. in 1st section on bucket weight ans:10kg, also there was a prob. on train speed to find bridge length ans:800 mtrs.
Highest level event class of the event-delegation model?