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, 22.06.2019 05:00
Modern businesses use different technologies to accomplish work tasks
Answers: 2
question
Computers and Technology, 22.06.2019 19:30
When creating a presentation in libre office impress, where does the editing of slides take place?
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
Singing in the rain: this first part of the film shows the early history of motion picture. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theater productions? explain.
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
Which option correctly describes a dbms application? a. software used to manage databases b. software used to organize files and folders c. software used to develop specialized images d. software used to create effective presentations
Answers: 1
You know the right answer?
Consider the getArea method from the textbook shown below.

public int getArea()
{<...
Questions
question
Mathematics, 25.01.2021 18:30
question
Mathematics, 25.01.2021 18:30
question
Mathematics, 25.01.2021 18:30
question
Mathematics, 25.01.2021 18:30
Questions on the website: 13722362