title: In java, Can we override a method by passing subclass of the parameter used in super class method?
body: <p>As per the rule, while overriding a method in subclass, parameters cannot be changed and have to be the same as in the super class. 
  What if we pass subclass of parameter while overriding method ? 
  Will it be called as overloading or overriding?</p>
  
  <p>Based on my query I have written some code below.<br>
  I was expecting the output as "Dog eats Flesh Food" but to my surprise the output is "Animal eats Flesh Food" 
  Will appreciate if someone can explain how does Animal method gets called when the object assigned is of type Dog ?</p>
  
  <pre><code>    class Food {
          public String toString(){
              return "Normal Food";
          }
      }
  
      class Flesh extends Food {
          public String toString(){
              return "Flesh Food";
          }
      }
  
      class Animal {
          public void eat(Food food){
              System.out.println("Animal eats "+ food);
          }
      }
  
      class Dog extends Animal{
  
          public void eat(Flesh flesh){
              System.out.println("Dog eats "+ flesh);
          }
      }
  
      public class MyUtil {
  
          public static void main(String[] args) {
  
              Animal animal = new Dog(); 
  
              Flesh flesh = new Flesh();
  
              animal.eat(flesh);
          }
      }
  </code></pre>