Answer to Question #47304 in Programming & Computer Science for Suzan
2014-09-28T18:42:30-04:00
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
2014-11-17T12:48:12-0500
The answer to the question is available in the PDF file https://assignmentexpert.com/https://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
THANK YOU
Leave a comment