| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice TestPractice Test
About Exam
easy Solved by 1 students
Recursive Method Return Value
< Prev
Next >

Consider the following recursive method.

public int recursiveMethod(int n) {
  if (n == 1)
    return 1;
  else if (n > 1)
    return n + recursiveMethod(n - 2);
  else
    return 0;
}

What value is returned as a result of the call recursiveMethod(5)?

A

9

B

0

C

8

D

4

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy