Question: Laboratory Tasks Task 1 1. Using the principle of method overloading: Create a class Calculate to print the area of a square, a rectangle, and

 Laboratory Tasks Task 1 1. Using the principle of method overloading:

Laboratory Tasks Task 1 1. Using the principle of method overloading: Create a class Calculate to print the area of a square, a rectangle, and a circle. The class has three methods with the same name but a different number or type of parameters. The method for calculating the area of the rectangle has two parameters which are length and width respectively while the other method for calculating the area of the square has one int parameter which is the side of the square. While the method for calculating the area of the circle has one double parameter which is the radius of the circle. The three methods should return the area of the shape (not print). public int area(int x) // calculate square area public double area(double x.doubley) // calculate rectangle area public double area(doubler) // calculate circle area . 2. Create another class called Program, which has main method, in the main method test the 3 overloaded methods public class Program { public static void main(String[] args) { 3. Answer the following Question: Based on the method overloading concept, Explain if we can create the following method in java? If you are not able to create, discuss why? public int add(int aint breturn a+b:) public double addint a int b)return a+b;) public double add(double aint breturn a+b:) public void add(double a, int b)(System.out.println(a+b):) tes) D Focus I U P A 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!