Method Overloading Vs Method Overriding
Method Overloading: A feature that allows a class to have two or more methods having same name but different argument is said to be Method Overloading . Two methods are said to be overloaded if and only if both methods having the same name but different argument types. Also known as Static Binding , Compile-Time Polymorphism and Early Binding. class Calculate { public void area(int a) {//circle System.out.println("Area of Circle = " + (3.14 * a * a)); } public void area(int l, int b) { //rectangle System.out.println("Area of Rectangle= " + (l * b)); } } In above example, we have created two overloaded methods, first area() method prints area of circle and second area() method prints area of rectangle. Method Overriding: The methods declared in parent class are by default available in the child class through the inheritance . But sometimes child may not be fully satisfied with the parent class method implementation, then the child is allow ...