Q:

Java - Method Overloading

0

This Program is used to calculate various area using Method Overloading concept.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

class OverloadDemo

{

  void area(float x)

    {   

       System.out.println("\nthe area of the square is "+Math.pow(x, 2)+" sq units");   

    }

  void area(float x, float y)

    {

        System.out.println("\nthe area of the rectangle is "+x*y+" sq units");   

    }

    void area(double x)

    {

        double z = 3.14 * x * x;

        System.out.println("\nthe area of the circle is "+z+" sq units");   

    }

}

class Overload1

{

     public static void main(String args[])

            {

               OverloadDemo ob = new OverloadDemo();

               ob.area(5);

               ob.area(11,12);

               ob.area(2.5);

        }

}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now