This really depends on overloading and overriding if you did something like this:
public class Animal{}
public class Dog extends Animal{}
public class AnimalActivity{
public void eat(Animal a){
System.out.println("Animal is eating");
}
public void eat(Dog d){
System.out.println("Dog is eating");
}
}
then in the main class:
public static void main(String args[])
{
Animal a=new Animal();
Animal d=new Dog();
AnimalActivity aa=new AnimalActivity();
aa.eat(a);
aa.eat(d);
}
the result in the two cases will be: Animal is eating
but lets twist it some, lets have this:
public class Animal{
public void eat(){
System.out.println("Animal is eating");
}
}
then:
public class Dog extends Animal{
public void eat(){
System.out.println("Dog is eating");
}
}
then in the main class:
public static void main(String args[]){
Animal d=new Dog();
Animal a=new Animal();
a.eat();
d.eat();
}
now the result should be:
Animal is eating
Dog is eating
this is because overloading binds at compile time "static binding"
while overriding binds at run time "dynamic binding"