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:
Verified
Q22: A recursive method without a special terminating
Q26: Complete the code for the myFactorial recursive
Q27: Consider the getArea method from the textbook
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
Q32: How many recursive calls to the fib
Q33: Consider the getArea method from the textbook
Q36: 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