Solved

Consider the GetArea Method from the Textbook Shown Below: Public

Question 58

Multiple Choice

Consider the getArea method from the textbook shown below: public int getArea()
{
If (width <= 0) { return 0; } // line #1
If (width == 1) { return 1; } // line #2
Triangle smallerTriangle = new Triangle(width - 1) ; // line #3
Int smallerArea = smallerTriangle.getArea() ; // line #4
Return smallerArea + width; // line #5
}
If line #1 was eliminated from the method, what would be the result when calling getArea?


A) A negative or zero width would cause problems.
B) Nothing - the method would still work correctly.
C) We would lose our only recursive case.
D) A positive width would reduce the correct area by 1.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions