virtual method invocation in Java

Virtual method invocation is the invocation of the correct overridden method, which is based on the type of the object referred to by an object reference and not by the object reference itself. It's determined at runtime, not at compilation time.
```
abstract class Animal {
   public abstract void feed(); }
}
class Cow extends Animal {
   public void feed() { addHay(); }
   private void addHay() { }
}
public void feedAnimal(Animal animal) {
   animal.feed();
}
```
Notice how this technique is called virtual method invocation. Instance variables don’t work this way.