Multiple Choice
Consider the getArea method from the textbook shown below. public int getArea()
{
If (width <= 0) { return 0; } // line #1
Else if (width == 1) { return 1; } // line #2
Else
{
Triangle smallerTriangle = new Triangle(width - 1) ; // line #3
Int smallerArea = smallerTriangle.getArea() ; // line #4
Return smallerArea + width; // line #5
}
}
Assume line #1 is replaced with this line:
If (width <= 0) {return width;}
What will be the result?
A) The method will still return correct results for all non-negative width triangles.
B) The method will return incorrect results for triangles with width equal to 0.
C) The method will return incorrect results for triangles with width equal to 1.
D) The method will return area to be one too high for all triangles.
Correct Answer:

Verified
Correct Answer:
Verified
Q31: If recursion does not have a special
Q32: Consider the getArea method from the textbook
Q33: Would switching the special case order affect
Q34: Given the following code snippet: public static
Q35: Consider the getArea method from the textbook
Q37: Consider the getArea method from the textbook
Q38: Consider the getArea method from the textbook
Q39: Insert the missing code in the following
Q40: Consider the recursive version of the fib
Q41: Consider the recursive method myPrint shown in