Java Program to Find Area of Square Using Method Overloading Last Updated : 08 Sep, 2022 Comments Improve Suggest changes Like Article Like Report A square is a simple flat shape in a plane, defined by four points at the four corners. It has four sides with equal length and four corners with right angles. Method Overloading: Method overloading allows different methods to have the same name, but different signatures where the signature can differ by the number of input parameters or type of input parameters, or both. In this article, we will learn how to find the area of the square using the method overloading. Area of the Square The area of the square is the square of its sides. We can simply calculate the area of the square using the following formula: Formula: Area of the Square: A = a2 Here, a is the side of the square. Below is the implementation of the above approach: Example 1: Showing the method overloading of Area() function which has different parameters of square sides of different data-type( float , int , double) Java // Java program to find the area of // the square using Method Overloading // of parameters with different datatype // of sides import java.io.*; class Square { // Overloaded Area() function to // calculate the area of the square // It takes one double parameter void Area(double side) { System.out.println("Area of the Square: " + side * side); } // Overloaded Area() function to // calculate the area of the square // It takes one float parameter void Area(float side) { System.out.println("Area of the Square: " + side * side); } } class GFG { // Driver code public static void main(String[] args) { // Creating object of square class Square obj = new Square(); // Calling function obj.Area(10); obj.Area(3.2); } } OutputArea of the Square: 100.0 Area of the Square: 10.240000000000002 Example 2: Showing method overloading of Area() function which returns the area of different figures like( square, circle, rectangle) Java // Java program to find the area of // the multiple shapes // using Method Overloading import java.io.*; class Shape { static final double PI = Math.PI; // Overloaded Area() function to // calculate the area of the square // It takes one float parameter void Area(float a) { float A = a * a; System.out.println("Area of the Square: " + A); } // Overloaded Area() function to // calculate the area of the circle // It takes one double parameter void Area(double a) { double A = PI * a * a; System.out.println("Area of the Circle: " + A); } // Overloaded Area() function to // calculate the area of the rectangle // It takes two int parameters void Area(int a, int b) { int A = a * b; System.out.println("Area of the Rectangle: " + A); } } class GFG { // Driver code public static void main(String[] args) { // Creating object of Shape class Shape obj = new Shape(); // Calling function obj.Area(10.5); obj.Area(3); obj.Area(5, 4); } } OutputArea of the Circle: 346.36059005827474 Area of the Square: 9.0 Area of the Rectangle: 20 Time complexity: O(1) because it is doing constant operations Auxiliary space: O(1) Comment More infoAdvertise with us Next Article Java Program to Find Area of Square Using Method Overloading ankita_saini Follow Improve Article Tags : Java Java Programs Practice Tags : Java Similar Reads Java Program to Find Area of Rectangle Using Method Overloading A rectangle is a simple flat figure in a plane. It has four sides and four right-angles. In a rectangle all four sides are not of equal length like a square, sides opposite to each other have equal length and both the diagonals of the rectangle have equal length. Method overloading allows different 2 min read Java Program to Find Area of circle Using Method Overloading A circle is a simple shape consisting of all the points in the plane that are equidistant from a point known as the center of the circle. In this article, we will learn how to find the area of the circle using the method overloading. Terminology: Method Overloading: Method overloading allows differe 3 min read Java Program to Find the Area of Parallelogram A parallelogram is a special type of quadrilateral that has equal and parallel opposite sides. The diagonals of a parallelogram bisect each other at 90 degrees. The area of a figure can be defined in geometry as the space occupied by a flat shape. A figure's area is the number of unit squares that c 3 min read Java Program to Find the Area of a Triangle A triangle is a polygon. It has three edges and three vertices and each vertex from an angle. It is a closed 2-dimensional shape. In this article, we will learn how to find the area of the triangle.There can be two possibilities while calculating the area of the triangle as per casesUsing the height 3 min read Java Program to Find the Area of Trapezium A trapezium is a convex quadrilateral, which has only two parallel sides and the other two sides are non-parallel. The non-parallel sides of the trapezium are referred to as its legs while the parallel sides are called the bases. It is also called a trapezoid. A parallelogram is also often referred 2 min read Java Program to Find the Area of Rhombus A rhombus is a quadrilateral whose four sides all have the same length and a rhombus is also called an equilateral quadrilateral. The formula for finding the area of a rhombus is as follows: (product of the lengths of the diagonals)/2 Example: Input : p = 2, q = 3 Output: 3Input : p = 4, q = 5 Outpu 1 min read Java Program to Find out the Area and Perimeter of Rectangle using Class Concept The perimeter is the length of the outline of a shape. To find the perimeter of a rectangle or square you have to add the lengths of all four sides. x is in this case the length of the rectangle while y is the width of the rectangle. The area is the measurement of the surface of a shape. The main ta 3 min read Java Program to Find the Perimeter of a Rectangle A Rectangle is a quadrilateral with four right angles (90°). In a rectangle, the opposite sides are equal. A rectangle with all four sides equal is called a Square. A rectangle can also be called as right angled parallelogram. Rectangle In the above rectangle, the sides A and C are equal and B and D 2 min read Java Program to Find the Volume and Surface Area of Sphere A sphere is a geometrical object in 3D space that is the surface of a ball. The sphere is defined mathematically as the set of points that are all at the same distance of radius from a given point in a 3D space. Example: Input: radius = 5 Output: Surface Area â 314.16 Volume â 523.6 Input : radius = 1 min read Java Program to Find the Volume and Surface Area of Cuboid A Cuboid is a 3-dimensional box-like figure represented in the 3-dimensional plane. A cuboid has 6 rectangle-shaped faces. Each face meets another face at 90 degrees each. Three sides of cuboid meet at the same vertex. Since it is made up of 6 rectangle faces, it has length, width and height of diff 2 min read Like