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
}
Assume line #3 is changed to this:
Triangle smallerTriangle = new Triangle(width + 1)
When calling the getArea method on a Triangle object with width = 4, what result will be produced?
A) area for all triangles will be computed to be too high
B) area for all triangles will be computed to be too low
C) area will only be incorrect for a triangle objects with width = 1
D) infinite recursion will occur for triangle objects with width >= 2
Correct Answer:
Verified
Q22: A recursive method without a special terminating
Q28: Consider the method powerOfTwo shown below:
Public boolean
Q29: Insert the missing code in the following
Q29: _ recursion can occur when a recursive
Q30: Consider the method powerOfTwo shown below:
Public boolean
Q30: If recursion does not have a special
Q31: Consider the getArea method from the textbook
Q32: How many recursive calls to the fib
Q36: Consider the getArea method from the textbook
Q38: Consider the getArea method from the textbook
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents