| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
hard Solved by 9 students
Tracing Mutual Recursive Methods
< Prev
Next >

What is the output of the following program?

public class MutualRecursion {
    public static int a(int n) {
        if (n <= 0) return 0;
        return n - b(n-1);
    }
    public static int b(int n) {
        if (n <= 0) return 0;
        return n - a(n-1);
    }
    public static void main(String[] args) {
        System.out.println(a(3));
    }
}
A

3

B

0

C

1

D

2

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2parth.taur22722 2m 30s 50
#3lsj0803092211 1m 15s 25
#4richa.tuli12 2m 33s -63
#5bommasam00011 2m 56s -76
#6chunxiangxu.cxu01 8m 10s -500
#7liuwilliam07241012 2h 20m -8,359
Items per page:
10
1 – 7 of 7
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy