I'm in hurry, so please study my following code which I've prepared for you in order to explain issues such as polymorphism, overrriding and overloading:
The output is the following:
LaserPrinter prints 3 pages
Printer does tilt
Printer does second tilt
LaserPrinter does klimbim within 10 seconds
Ok, maybe it's a stupid example, but in any case, you can study the differences between reference type (left-side) and instance type (right-side).
Please take into account, that the instance type must pass the IS A test according to the reference type:
as you can see, LaserPrinter IS A Printer (the contrary is not true, a Printer IS NOT a LaserPrinter, an Animal IS NOT a cat, etc.)
If something remains unclear, I'll come back to you tomorrow!
(My guests are already waiting for dinner...)
Here's a way to think about what happens at compile time and then later at run time.
The declared variable type determines what methods are available to be called - the
type's list of method behaviors. The compiler checks your code for valid calls to the
variable type's methods and allows calls on any type that has at least those behaviors.
It doesn't care that it may have more methods, or overrides of some of the variable
type's methods. Later at run time, the JVM gives first shot to any overriding method
the assigned object may have.