Difference between method overloading and overriding:
Method overloading:
1. If the same method name is used with different arguments, then it is called method overloading.
Ex:
void sum(int x,int y)
void sum(int x,int y,int z)
2. Method overloading will be done with in the same class.
3. Method overloading is an example of static polymorphism.
Method overriding:
1.If the we define the same method name in the super class and sub class, then sub class method will override the super class method. This is called method overriding.
2. Method overriding is done only when there is a super and sub class.
3.Method overriding is an example of run time polymorphism.