Saturday, April 8, 2017

Polymorphism Concepts

Polymorphism is one of main four concepts in Java. The word polymorphism means many forms. That means it has many different kinds of forms. There are two types of polymorphism: dynamic and static. Actually it has many ways to describe polymorphism but in fact it refers to method overridding and overloading concepts.

What is method overriding and overloading ?

Method overridding: There are two methods with same name as they share same method signature. Method signature includes data types, number, sequence and return type. Technically speaking method overridding can have different return types but it should obey some rules that return type of overridding method should be the same or a subtype of its overridden method in parent class.

Method overloading: Method overloading is similar to method overridding. It has same method name but different method signature. Return type doesn't matter for method overloading, It can be same or different.

No comments:

Post a Comment

Abstraction vs Interface

Abstract Interface method abstract and concrete abstract only, support default and static method ...