Question: Consider the following implementation of a class Square: public class Square { private int sideLength; private int area; // Not a good idea public Square(int
Consider the following implementation of a class Square:

public class Square { private int sideLength; private int area; // Not a good idea public Square(int length) { side Length = length; } public int getArea() { } area side Length side Length; return area; } Why is it not a good idea to introduce an instance variable for the area? Rewrite the class so that area is a local variable.
Step by Step Solution
There are 3 Steps involved in it
The given implementation of the class Square contains an instance variable for area which is not good practice As a general rule instance variables sh... View full answer
Get step-by-step solutions from verified subject matter experts
