Overloading vs Overriding

Overloading occurs when two or more methods in one class have the same method name but different parameters.

Overriding means two methods with the same method name and parameters. One is in the parent class and the other is in the child class. Overriding allows a child class to provide a specific implementation of a method that is already provided its parent class. 

Overloading happens at compile-time; Overriding happens at runtime.

Static binding is being used for overloaded methods and dynamic binding is being used for overridden/overriding methods.

猜你喜欢

转载自blog.csdn.net/chaoren499/article/details/87876439