Hi, today I will discuss about Polymorphism. I decided to post this after my Object Oriented Software Engineering Exam to share it with you guys.So, to help you understand the concept of Polymorphism easy with easy example, that I wrote myself.Thats, why they are easy to understand.
Ok. lets Start know.
What is Polymorphism?
Polymorphism means many forms its the most complex among, abstraction, inheritance and encapsulation.
Example: The “+” plus sign
In lots of languages more specifically talking about “Java” as in first year of my BSc honours in Computing at National College of Ireland. I studied Polymorphism in Java.
Ok, continuing with the example –
If, we have “a+b”
and if the values provided for “a” and “b” are integers , like a=1 and b=2
It will automatically add and we get a+b = 1+2 = 3 as result.
but if the values are Strings it will flomax online cheap conciliate them –
a=”Hello” and b=”World”
a+b = HelloWorld as result
Thats, what polymorphism is.
Another Example very specific to Java
In, Polymorphism for example we are Inheriting some classes from a parent class.
Since, We know a inherited class use the behavior of the parent class.In polymorphism, for an instance think we have a bank account class with a behavior “withdraw” and a child class has a situation that simple withdraw behavior is not sufficient.In,this case
We @Override the default behavior and write rules for withdraw within that child class to use for just that class whenever needed.
I hope it helped.For any questions comment below or start a topic in Navsingh Forum
or check out the Object Oriented Software Engineering Forum