Solved

Consider the GetArea Method from the Textbook Shown Below

Question 27

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:

verifed

Verified

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

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents