WHAT IS POLYMORPHISM?
Poly means many forms. So it is basically means different types of the object. Polymorphism is a way of defining multiple functionalities under the same name. In other words we can say that we have the same code or operation but it will behave differently in different contexts.IMPORTANT POINTS ABOUT POLYMORPHISM
- A functionality can behave differently for different instances
- The behavior depends on the type of data used in the operation
- Polymorphism is used for implementing inheritance.
ADVANTAGES OF POLYMORPHISM
- It helps programmers reuse the code and classes once written, tested and implemented. They can be reused in many ways.
- Single variable name can be used to store variables of multiple data types(Float, double, Long, Int etc).
- Polymorphism helps in reducing the coupling between different functionalities.
DISADVANTAGES OF POLYMORPHISM
- One of the disadvantages of polymorphism is that developers find it difficult to implement polymorphism in codes.
- Run time polymorphism can lead to the performance issue as machine needs to decide which method or variable to invoke so it basically degrades the performances as decisions are taken at run time.
- Polymorphism reduces the readability of the program. One needs to identify the runtime behavior of the program to identify actual execution time.
Read More:
Pros and Cons of Inheritance in OOPS
What Is Inheritance in Java?
Load Testing vs Stress Testing
Copyright © ianswer4u.com
0 Reactions:
Post a Comment