class Base{ public void method(String s){ } } class Derived extends Base{ public void method(Object o){ } } Are we overriding the method()??? I know that the signature should me same for overriding. Please comment on this.
No, you are just defining a method in the subclass which will not be available through a base object reference. It just happens to have the same name as that defined in the base class, that's all. However,
will not compile because the compiler can not resolve the ambiguity of calling Base.method(String) or Derived.method(Object). -Barry [ November 01, 2002: Message edited by: Barry Gaunt ]
If two methods of a class (whether both declared in the same class, or both inherited by a class, or one declared and one inherited) have the same name but different signatures, then the method name is said to be overloaded.