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 are variable arguments or varargs?
What is collections framework?
What is the java virtual machine?
What exceptions occur during serialization?
Why can't you declare a class as protected?
What is the null?
Can you sort a string in java?
What are the Class Libraries ?
What is the common usage of serialization? What exceptions occur during serialization?
What is the program compilation process?
What ide should I use for java?
What is the purpose of nested class in java?
What is difference between filereader and bufferedreader?
What is data string?
What is the difference between length and length () in java?