Polymorphism
What is Polymorphism?
Polymorphism is often referred to as the third pillar of object-oriented programming, after encapsulation and inheritance. Polymorphism is a Greek word that means "many-shaped".
PolyMorphism = Many Shaped
Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. [To Be Discussed - TBD]
The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity can take many forms.
In Java, polymorphism allows the same method or object to behave differently based on the context, specially on the project's actual runtime class. [TBD]
Key features of polymorphism:
Multiple Behaviors: The same method can behave differently depending on the object that calls this method.
Method Overriding: A child class can redefine a method of its parent class.
Method Overloading: We can define multiple methods with the same name but different parameters.
Runtime Decision: At runtime, Java determines which method to call depending on the object's actual class.
payilagam
References:
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/object-oriented/polymorphism
https://www.geeksforgeeks.org/java/polymorphism-in-java/
Top comments (0)