Polymorphism in action
Polymorphism is the most powerful and useful feature of OOP. It uses all the other OOP concepts and features we have presented so far. It is the highest conceptual point on the way to mastering Java programming. After discussing it, the rest of the book will be mostly about Java language syntax and JVM functionality.
As we stated in the OOP concepts section, polymorphism is the ability of an object to behave as an object of different classes or as an implementation of different interfaces. If you search the word polymorphism on the internet, you will find that it is the condition of occurring in several different forms. Metamorphosis is a change of the form or nature of a thing or person into a completely different one, by natural or supernatural means. So, Java polymorphism is the ability of an object to behave as if going through a metamorphosis and to exhibit completely different behaviors under different conditions.
We will present this concept in...