Please note that
is not a valid override of
since the parameter types are not same. You are overloading method m1().
Since the method to be called is decided on the reference type, a.m1() calls the method in class A and b.m1() calls the method in class B.
but when i remove the vaar args
You mean the method signature in class A becomes
This causes the method in class B to override the one in class A and by the rules of dynamic dispatch, you get the method in class B getting executed for both the calls.
[ December 25, 2006: Message edited by: Aniket Patil ]