Please log in to purchase this document.

AP Computer Science study set

EXAM ELABORATIONS Aug 27, 2025
Loading...

Loading document viewer...

Page 0 of 0

Document Text

1 Brittie Donald, All Rights Reserved © 2025 AP Computer Science study set Chapter 13 Exam Questions and Answers 100% Pass

1) What is required to make a recursive method successful?I special cases that handle the simplest computations directly II a recursive call to simplify the computation III a mutual recursion

a) I b) II

c) I and II d) I, II, and III - ✔✔c

2) 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 1 / 4

2 Brittie Donald, All Rights Reserved © 2025 else { Triangle smallerTriangle = new Triangle(width - 1); // line #3 int smallerArea = smallerTriangle.getArea(); // line #4 return smallerArea + width; // line #5 } } Where is/are the recursive call(s)?

  • line #1 b) line #2
  • lines #1 and #2 d) line #4 - ✔✔d
  • 3) 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

{ 2 / 4

3 Brittie Donald, All Rights Reserved © 2025 Triangle smallerTriangle = new Triangle(width - 1); // line #3 int smallerArea = smallerTriangle.getArea(); // line #4 return smallerArea + width; // line #5 } } Where is/are the terminating condition(s)?

  • line #1 b) line #2
  • lines #1 and #2 d) line #4 - ✔✔c

4) 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 3 / 4

4 Brittie Donald, All Rights Reserved © 2025 return smallerArea + width; // line #5 } }

Assume the code in line #3 is changed to: Triangle smallerTriangle = new

Triangle(width); This change would cause infinite recursion for which triangles?

a) Those with width equal to 0.

b) Those with width equal to 1.

c) Those with width greater than or equal to 2.

d) Triangles of any width. - ✔✔c

5) Consider the getArea method from the book shown below.public int getArea() { if (width <= 0) { return 0; } // line #1 else if (width == 1) { return 1; } // line #2 else {

  • / 4

Download Document

Buy This Document

$30.00 One-time purchase
Buy Now
  • Full access to this document
  • Download anytime
  • No expiration

Document Information

Category: EXAM ELABORATIONS
Added: Aug 27, 2025
Description:

Brittie Donald, All Rights Reserved © 2025 AP Computer Science study set Chapter 13 Exam Questions and Answers 100% Pass 1) What is required to make a recursive method successful? I special cases ...

Get this document $30.00