I have classes as follows
public class Useful
{
public void f(Object a)
{
System.out.println("In base f");
}
public void g(String a)
{
System.out.println("In base g");
}
}
public class MoreUseful extends Useful
{
public void f(String a)
{
System.out.println("In derived f");
}
public void g(Object a)
{
System.out.println("In derived g");
}
}
I am trying to override base class method but I am changing the parameters in derived class. in method MoreUseful.f() I am using subclass parameter (String) as against Object in base class. in method MoreUseful.g() I am using superclass parameter (Object) as against String in base class.
Is it possible to override these way? Which of the above two cases will be correct overriding?