-
chevron_right
Polymorphism and inheritance in Java
pubsub.slavino.sk / infoworldcom • 13 June, 2024 edit
Polymorphism —or an object's ability to execute specialized actions based on its type—is what makes Java code flexible. Many design patterns created by the Gang Of Four rely on some form of polymorphism, including the Command pattern . In this article, you will learn the basics of Java polymorphism and how to use it in your programs.
Things to know about Java polymorphism
- Polymorphism and Java inheritance
- Why polymorphism is important
- Polymorphism in method overriding
- Polymorphism with the core Java classes
- Polymorphic method calls and casting
- Reserved keywords and polymorphism
- Common mistakes with polymorphism
- What to remember about polymorphism
Polymorphism and Java inheritance
We will focus on the relationship between polymorphism and Java inheritance . The main thing to keep in mind is that polymorphism requires an inheritance or an interface implementation. You can see this in the example below, featuring Duke and Juggy:
To read this article in full, please click here