Recursive Method Return Value
Which of the following could be used to replace /* missing code*/ so that the value of mystery(10) is 32?
Consider the following incomplete method:
public int mystery(int x)
{
if (x <= 1) {
return 1;
} else {
return ( /* missing code*/ );
}
}
Which of the following could be used to replace /* missing code*/ so that the value of mystery(10) is 32?
A
4 + mystery(x – 1)
B
4 * mystery(x – 4)
C
2 * mystery(x – 2)
D
2 * mystery(x – 1)
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE