What errors does this class have How would you fix them Rewr

What errors does this class have? How would you fix them? Rewrite the correct version of this class. public class Square {private double sideLength; private double area; public Square(double sideLength) {sideLength = sideLength;} public double getArea() {area = sideLength * sideLength; return area;} public static void main(string[] args){Square sq = new Square(4.4); System.out.print(\"This Area of the square is:\\t +sq. getArea);

Solution

correct code is given below--->

Square.java

public class Square{
    private double sideLength;
    private double area;
  
   public Square(double squareOne)
   {
       sideLength = squareOne;
   }
        public double getArea(){
            area=sideLength*sideLength;
            return area;
            }

            public static void main(String[] args)
        {
            Square sq=new Square(4.4);
            System.out.print(\"This area of the square:\\t\" + sq.getArea());
            }
}

Output :

 What errors does this class have? How would you fix them? Rewrite the correct version of this class. public class Square {private double sideLength; private do

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site