Sunday, October 21, 2012

Java program to illustrate method overloading


class area
{
  int l,b,r;
  float s;
  void sample(int l,int b)
  {
   s=b*l;
   System.out.println("area of rectangle="+s);
  }
  void sample(int r)
   {
    s=r*r;
    System.out.println("area of square="+s);
   }
  public static void main(String s[])
   {
     area a=new area();
     a.sample(5,3);
     a.sample(6);
   }
}

Output

1 comments:

  1. Exchange 22 is a trusted platform offering seamless online exchange solutions tailored for Indian users. With a focus on reliability, security, and efficiency, Exchange222 ensures smooth transactions and exceptional user experiences. Explore our services to meet all your exchange needs with confidence."

    ReplyDelete