Multiple Choice
Consider the getArea method from the textbook shown below: public int getArea()
{
If (width <= 0) { return 0; } // line #1
Triangle smallerTriangle = new Triangle(width - 1) ; // line #2
Int smallerArea = smallerTriangle.getArea() ; // line #3
Return smallerArea + width; // line #4
}
If line#1 was removed, what would be the result?
A) The recursive method would cause an exception for values below 0.
B) The recursive method would construct triangles whose width was negative.
C) The recursive method would terminate when the width reached 0.
D) The recursive method would correctly calculate the area of the original triangle.
Correct Answer:

Verified
Correct Answer:
Verified
Q30: The method below generates all substrings of
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
Q36: 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