Differentiate between Overloading and Overriding


OVERLOADING VS OVERRIDING
OVERLOADING
OVERRIDING
·         overloading is a compile time polymorphism.
·         overriding is a runtime polymorphism.
·         it means “add” more behavior.
·         it means “change” existing behavior.
·         in overloading the parameters should be unique i.e. the number of parameters should differ or the type would be different. This is because compiler should know the methods in compile time only.
·         In overriding, we re-implement or change the functionality of the base class method in derived class the number of parameter and return type should be same.
·         They appear in the same class or a subclass.
·         It appears in subclass.
·         There is relationship between methods available in the same class.
·         There is relationship between a superclass method and subclass method.
·         Overloading does not block inheritance from the superclass.
·         Overriding blocks inheritance.

1 comment:

  1. What is difference between overriding and overloading in object oriented programming? Nice

    ReplyDelete

Feel free to contact the admin for any suggestions and help.