Polymorphism in Java
OOP's a very important jargon in the programming world, and many of us are familiar with this word, Object oriented Programming. Polymorphism is a main pillar of OOP,s by definition it is the ability of an object to take on many forms.
But the main Question is what these lines really means "the ability of an object to take on many forms".
So to clear this fog from my fellow programmers . Polymorphism can easily be understood
with the help of the following example
Suppose there is a super class Shape and to sub classes Circle and Rectangle, both Rectangle and Circle extends Shape.
so the magic of polymorphism is "the reference of the parent class (Shape) is used to refer to a child class object
Shape s1=new Rectangle(1, 3);
Shape s2=new Circle(2);
Object o1=new Circle(4);
Object o1=new Rectangle(4, 3);
0 Comment(s)