title: Can I override using subclass object as parameter in Java?
body: <p>I have classes as follows</p>
  
  <pre><code>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");
      }
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>Is it possible to override these way?
  Which of the above two cases will be correct overriding?</p>