Hi guys i'm studying for an exam and there's the following question
public class Square {
public static void main(String[] args){
}
private int sideLength;
private int area;
public Square(int initiallength)
{
sideLength=initiallength;
area= sideLength*sideLength;
}
public int getArea(){
return area;
}
public void grow(){
sideLength=2*sideLength;
}
}
What error does this class have?How would you fix it?
Now iv written the code and compiled it to no errors. Also as the question says "error" i'm presuming it sone large error!The only thing i noticed is that in the class square it computes the area of the square and therefore the getArea() method is pointless. Is there something i'm missing?Any help would be great