Hi Aruna,
Always remember the following in
Java
For overloading, method in reference is used.
For overriding, method in the object is used.
The parent class "A" can accomodate all three class types "A", "B" and "C". Because it is the parent.
So, when you say
A c2 = new C(); c2.m1(a1);
JVM will look for the method "m1" in class A
Suppose, you give...
B c2 = new C(); in your code
your output will be "ABB"
And for the code
C c2 = new C(); in your code
your output will be "ABC"
Any more queries???
Regards,
Sriram