OOPs

24. Create a class showing the area of circle and rectangle by method overloading.

            class Area{
                double area(double radius){
                    return (Math.PI*radius*radius);
                }
                double area(double length, double breadth){
                    return length * breadth;
                }
            }
            class Main{
                public static void main(String[] args){
                    Area obj = new Area();
                    System.out.println("Area of Circle with radius = 5 : " +obj.area(5));
                    System.out.println("Area of Rectangle with length = 5 and breadth = 9 : " +obj.area(5, 9));
            
                }
            }  
        

OUTPUT

            Area of Circle with radius = 5 : 78.53981633974483
            Area of Rectangle with length = 5 and breadth = 9 : 45.0