Computers and Technology
Computers and Technology, 06.11.2019 22:31, cam961

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){
sidelength = length;
}
public int getarea(){
area = sidelength * sidelength;
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.

answer
Answers: 2

Similar questions

Do you know the correct answer?
Consider the following implementation of a class square:
public class square
{
pr...

Questions in other subjects:

Konu
Chemistry, 05.06.2020 02:01