AP CSA Unit 4.16

AP CSA Unit 4.16 MCQ Explanations

Multiple-choice answer key and concise explanations for Recursion.

Q1A
Q2C
Q3C
Q4B
Q5A
Q6A
Q7A
Q8B
How to use this page: Try the printed MCQ set first. Then compare your answer with the key and review the question card.

Answer Explanations

Q1

What is recursion?

AA method calling itself
BA loop that uses for
CA class with no methods
DAn array with two dimensions
Correct answer: A. The correct choice is A because the prompt leads to A method calling itself.
Explanation

For this question, focus on the values, method rule, or definition stated in the prompt. The selected answer is the one that matches that trace exactly.

  • B is not correct: it gives A loop that uses for, but the trace or rule tested by the prompt leads to A method calling itself.
  • C is not correct: it gives A class with no methods, but the trace or rule tested by the prompt leads to A method calling itself.
  • D is not correct: it gives An array with two dimensions, but the trace or rule tested by the prompt leads to A method calling itself.
Q2

What is a base case?

AThe first array index
BA static variable only
CA condition that stops the recursive calls
DA constructor parameter
Correct answer: C. The correct choice is C because the prompt leads to A condition that stops the recursive calls.
Explanation

For this question, focus on the values, method rule, or definition stated in the prompt. The selected answer is the one that matches that trace exactly.

  • A is not correct: it gives The first array index, but the trace or rule tested by the prompt leads to A condition that stops the recursive calls.
  • B is not correct: it gives A static variable only, but the trace or rule tested by the prompt leads to A condition that stops the recursive calls.
  • D is not correct: it gives A constructor parameter, but the trace or rule tested by the prompt leads to A condition that stops the recursive calls.
Q3

What is recursive progress?

AEach call repeats with exactly the same arguments forever
BThe method becomes void automatically
CEach call moves closer to a base case
DThe compiler removes every call
Correct answer: C. The correct choice is C because the prompt leads to Each call moves closer to a base case.
Explanation

For this question, focus on the values, method rule, or definition stated in the prompt. The selected answer is the one that matches that trace exactly.

  • A is not correct: it gives Each call repeats with exactly the same arguments forever, but the trace or rule tested by the prompt leads to Each call moves closer to a base case.
  • B is not correct: it gives The method becomes void automatically, but the trace or rule tested by the prompt leads to Each call moves closer to a base case.
  • D is not correct: it gives The compiler removes every call, but the trace or rule tested by the prompt leads to Each call moves closer to a base case.
Q4

What can happen if recursion has no reachable base case?

AThe program sorts automatically.
BThe program may run until a stack overflow occurs.
CThe array length changes.
DThe method returns 0 always.
Correct answer: B. The correct choice is B because the prompt leads to The program may run until a stack overflow occurs..
Explanation

For this question, focus on the values, method rule, or definition stated in the prompt. The selected answer is the one that matches that trace exactly.

  • A is not correct: it gives The program sorts automatically., but the trace or rule tested by the prompt leads to The program may run until a stack overflow occurs..
  • C is not correct: it gives The array length changes., but the trace or rule tested by the prompt leads to The program may run until a stack overflow occurs..
  • D is not correct: it gives The method returns 0 always., but the trace or rule tested by the prompt leads to The program may run until a stack overflow occurs..
Q5

Which recursive call for factorial(n) shows progress toward n == 0?

Afactorial(n - 1)
Bfactorial(n + 1)
Cfactorial("n")
Dfactorial(n)
Correct answer: A. The correct choice is A because the prompt leads to factorial(n - 1).
Explanation

For this question, focus on the values, method rule, or definition stated in the prompt. The selected answer is the one that matches that trace exactly.

  • B is not correct: it gives factorial(n + 1), but the trace or rule tested by the prompt leads to factorial(n - 1).
  • C is not correct: it gives factorial("n"), but the trace or rule tested by the prompt leads to factorial(n - 1).
  • D is not correct: it gives factorial(n), but the trace or rule tested by the prompt leads to factorial(n - 1).
Q6

Which part of a recursive method combines a smaller result with current work?

AThe recursive case
BThe file name
CThe class header only
DThe import statement
Correct answer: A. The correct choice is A because the prompt leads to The recursive case.
Explanation

For this question, focus on the values, method rule, or definition stated in the prompt. The selected answer is the one that matches that trace exactly.

  • B is not correct: it gives The file name, but the trace or rule tested by the prompt leads to The recursive case.
  • C is not correct: it gives The class header only, but the trace or rule tested by the prompt leads to The recursive case.
  • D is not correct: it gives The import statement, but the trace or rule tested by the prompt leads to The recursive case.
Q7

Which question should you ask when reading recursive code?

AWhat is the base case and how do arguments change?
BHow many public fields exist?
CDoes the method use length or size?
DIs the file in a folder?
Correct answer: A. The correct choice is A because the prompt leads to What is the base case and how do arguments change?.
Explanation

For this question, focus on the values, method rule, or definition stated in the prompt. The selected answer is the one that matches that trace exactly.

  • B is not correct: it gives How many public fields exist?, but the trace or rule tested by the prompt leads to What is the base case and how do arguments change?.
  • C is not correct: it gives Does the method use length or size?, but the trace or rule tested by the prompt leads to What is the base case and how do arguments change?.
  • D is not correct: it gives Is the file in a folder?, but the trace or rule tested by the prompt leads to What is the base case and how do arguments change?.
Q8

Which statement about recursion and iteration is true?

ARecursive methods cannot be static.
BSome problems can be solved with either recursion or loops.
CRecursion never uses return values.
DRecursion cannot have parameters.
Correct answer: B. The correct choice is B because the prompt leads to Some problems can be solved with either recursion or loops..
Explanation

For this question, focus on the values, method rule, or definition stated in the prompt. The selected answer is the one that matches that trace exactly.

  • A is not correct: it gives Recursive methods cannot be static., but the trace or rule tested by the prompt leads to Some problems can be solved with either recursion or loops..
  • C is not correct: it gives Recursion never uses return values., but the trace or rule tested by the prompt leads to Some problems can be solved with either recursion or loops..
  • D is not correct: it gives Recursion cannot have parameters., but the trace or rule tested by the prompt leads to Some problems can be solved with either recursion or loops..