Welcome to the Ranch
You can create a reference which is called by a particular type. Then you can make that reference point to an object of that type or any of its subclasses. If you create a reference to
Animal, then all its instance methods are available. If, for example, the
Horse class has a
buck() method, that might not be available in
Animal, so you cannot call it on an
Animal reference. You can, however, call the
eat() method, which is in the
Animal class (suggesting that all kinds of Animal eat, but only horses buck). When you call the
eat() method on an
Animal reference which points to a
Horse object, you use run-time binding, which finds the versipon of that method in the actual object, so you will execute the
Horse version.
Beware: don't try polymorphism on
static methods. It doesn't work.