Professional Documents
Culture Documents
The Difference Between Overloading and Over
The Difference Between Overloading and Over
Overloading Over-riding
Method overloading is a compile-time Method overriding is a run-time
polymorphism. polymorphism.
Method overloading helps to increase the Method overriding is used to grant the
readability of the program. specific implementation of the method that is
already provided by its parent class or
superclass.
It occurs within the class. It is performed in two classes with inheritance
relationships.
Method overloading may or may not require Method overriding always needs inheritance.
inheritance.
Poor Performance due to compile time Polymorphism. It gives better performance.
polymorphism. The reason behind this is that the binding of
overridden methods is being done at runtime.
Use of interface
Use to achieve total abstraction.
It is also used to achieve loose coupling.
Interfaces are used to implement abstraction.
It can achieve multiple inheritance.
Public: -
The public modifier allows public field and public Method to be accessed from any other class.
Protected: - The protected modifier allows protected Field and protected Method to be
accessed within the same package or by subclasses of Protected Example.