| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice Test
Share
medium Solved by 1 students
Recursive Method Tracing
< Prev
Next >

What will be output as a result of the method call processNumber(5)?
Consider the following method processNumber.

public static void processNumber(int n) {
    if (n <= 1) System.out.print(n);
    else {
        processNumber(n - 2);
        System.out.print(n % 2);
    }
}

What will be output as a result of the method call processNumber(5)?

A

101

B

100

C

001

D

111

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

Question Leaderboard

Not enough data yet to show leaderboard.

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