subject

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 area to be one too high for all triangles.
c. The method will return incorrect results for triangles with width equal to 0.
d. The method will return incorrect results for triangles with width equal to 1.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 05:00
In cell b18, enter a formula to calculate the amount budgeted for meals. this amount is based on the daily meal allowance and the total travel days (# of nights+1).
Answers: 1
question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
question
Computers and Technology, 23.06.2019 10:00
Hey i just logged on and one of the moderators deleted a bunch of my answers to questions, even though the answers were right and the people it doesn't make sense but if anyone wants to talk about anything just message me lol (this is super random lol)
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
The option enables you to modify a slide element in most presentation applications.
Answers: 2
You know the right answer?
Consider the getArea method from the textbook shown below.

public int getArea()
{<...
Questions
question
History, 07.02.2021 19:50
Questions on the website: 13722362