Friday, 13 September 2013

Method Overloading in java program

class Test{
int area(int i){
return i*i;

int area(int a, int b){
return a*b;


public class MethodOverloading {

        public static void main(String[] args) {
            Test t = new Test();
            int area;
            area = t.area(5); 
            System.err.println("Area of a square is :"+area);
            area = t.area(5,6);
            System.out.println("Area of a rectangle is :"+area);