Quiz Questions for APCSA Unit 10
Questions and Code Cells for the Quiz on Unit 10
Unit 10: Recursion
Which of the following is an example of a recursive method?
a) A method that calls itself
b) A method that calls another method
c) A method that runs indefinitely
d) A method that returns a value
Answer: a) A method that calls itself
What is the base case in a recursive method?
a) The condition under which the method stops calling itself
b) The first call to the recursive method
c) The last call to the recursive method
d) The condition under which the method calls itself
Answer: a) The condition under which the method stops calling itself
What will be the output of the following recursive method when called with factorial(3)?
public int factorial(int n) {
if (n == 0) {
return 1;
}
return n * factorial(n - 1);
}
a) 6
b) 3
c) 0
d) 1
Answer: a) 6