Method Overloading | Method Overriding |
Method Overloading is about the same function have different signatures. | Method Overriding is about the same function, same signature but different classes connected through inheritance. |
Method Overloading is a concept of compile-time polymorphism | Method Overriding is a concept of run time polymorphism. |
Method Overloading Example:
public class Employee { public void print() { //some code here } public void print(String name) { //some code here } public void print(Employee employee) { //some code here } } |
Method Overriding Example:
public class Person { public void print(String name) { //some code here } } public class Employee extends Person { @Override public void print(String name) { //some code here } } |
See Also: Java Method Overloading in Detail | See Also: Java Method Overriding in Detail |
See Also: