## Problem Statement

Write a program to create a class Area and calculate the area of the rectangle and circle using method overloading.

## Solution

``````class Area {
// Method to calculate the area of a rectangle
double calculateArea(double length, double width) {
return length * width;
}

// Method to calculate the area of a circle
}
}

public class AreaCalculator {
public static void main(String[] args) {
// Create an object of the Area class
Area areaCalculator = new Area();

// Calculate and print the area of a rectangle
double rectangleArea = areaCalculator.calculateArea(5.0, 3.0);
System.out.println("Area of the rectangle: " + rectangleArea);

// Calculate and print the area of a circle
double circleArea = areaCalculator.calculateArea(2.5);
System.out.println("Area of the circle: " + circleArea);
}
}
``````

In this Java program:

1. We define a class called `Area`.
2. Inside the `Area` class, we have two methods with the same name `calculateArea`, but they differ in the number and types of parameters. This is method overloading.
3. The first `calculateArea` method takes two parameters (length and width) and calculates the area of a rectangle.
4. The second `calculateArea` method takes one parameter (radius) and calculates the area of a circle.
5. In the `main` method, we create an object `areaCalculator` of the `Area` class.
6. We call the `calculateArea` method with different sets of arguments to calculate the area of both a rectangle and a circle.
7. Finally, we print the calculated areas for the rectangle and circle.

When you run this Java program, it will calculate and display the areas of the rectangle and circle using method overloading.

Spring Framework Practice Problems and Their Solutions

From Google to the World: The Story of Go Programming Language

Why Go? Understanding the Advantages of this Emerging Language

Creating and Executing Simple Programs in Go

20+ Interview Questions on Go Programming Language

Java Practice Exercise

Princites
{"ft_lang_label":"__label__en","ft_lang_prob":0.6780877,"math_prob":0.96047443,"size":2220,"snap":"2023-40-2023-50","text_gpt3_token_len":503,"char_repetition_ratio":0.18095668,"word_repetition_ratio":0.10335196,"special_character_ratio":0.22387387,"punctuation_ratio":0.11466666,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9980411,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-28T22:42:54Z\",\"WARC-Record-ID\":\"<urn:uuid:fd632d3f-3ecf-493a-b323-439854b324de>\",\"Content-Length\":\"78401\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:859aeb35-2970-4240-9e18-1fcc4df71ee2>\",\"WARC-Concurrent-To\":\"<urn:uuid:9083a12d-e077-495c-9015-a6551c3bc93a>\",\"WARC-IP-Address\":\"68.178.221.138\",\"WARC-Target-URI\":\"https://www.programmingempire.com/example-of-method-overloading-in-java-2/\",\"WARC-Payload-Digest\":\"sha1:SCWBVENWLKA5H7LXERQGJTKPLKKGNSHI\",\"WARC-Block-Digest\":\"sha1:BRL4SAW57B4UO6HM64DWK3YQBTG64ADJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100016.39_warc_CC-MAIN-20231128214805-20231129004805-00556.warc.gz\"}"}