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 gui programming?
What two classes are used to read data only?
Can we have more than one package statement in the source file?
Can we catch more than one exception in single catch block?
What does java edition mean?
What is close method? How it's different from Finalize & Dispose?
What is an example of a boolean?
Can we restart a dead thread in java?
Is int a class in java?
Why is multiple inheritance not supported in java?
whar are the draw backs of programming lang step by step in Clang and next in C++ and next and in Java nad in .Net
Explain the selection sort algorithm?
What does replaceall do in java?
Can we declare register variable as global?
Do you know how to reverse string in java?