Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
hard Solved by 1 students

Recursive String Method Output

Mark
< Prev
Next >

What is printed when the following code is executed?

public class CustomReverse {
    public static String customRev(String s) {
        if(s.length() <= 1) return s;
        return s.charAt(0) + customRev(s.substring(1)) + s.charAt(0);
    }
    public static void main(String[] args) {
        System.out.println(customRev("ab"));
    }
}
A

baa

B

abab

C

aba

D

abba

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.

AI Tutor

How can I help?

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