Answer to Question #47304 in Programming & Computer Science for Suzan

Question #47304
Consider the following implementation of a class Square:

public class Square
{
privateintsideLength;
privateint area; // Not a good idea

public Square(int length){
sideLength = length;
}
publicintgetArea(){
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.
1
Expert's answer
2014-11-17T12:48:12-0500
The answer to the question is available in the PDF file https://www.assignmentexpert.com/https://www.assignmentexpert.com/homework-answers/programming-answer-47304.pdf

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Suzan
29.09.14, 01:44

THANK YOU

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS