-
Polymorphism.
Hi,
Im just trying to get the right idea about polymorphism.
Is polymorphism simply the act of inheriting an abstract class and defining the methods yourself. As polymorphism means many forms, do we call this polymorphism because the abstract class can have many forms?
Thanks.
-
Re: Polymorphism.
Umm... Close. First, the superclass doesn't have to be abstract for polymorphism to be relevant.
The Oracle tutorials say that "Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class."
So, the methods and fields of the superclass are taking a different form in a new object defined by the subclass, yet they can have the same functions in the subclass as they do in the superclass. This idea also includes overriding and hiding methods and fields. Check out the Oracle tutorials on Polymorphism, as well as the Inheritance section.
-
Re: Polymorphism.
So polymorphism is the act of inheriting a class and overriding methods from it/adding to it, so making a class based on another. And as polymorphism means many forms, we call this polymorphism because the superclass can have many forms. Cheers!
I read the links you posted, thanks.