Consider:
<code class="language-java">public static String r(String s) { if (s.length() <= 1) return s; return r(s.substring(1)) + s.charAt(0); } </code></pre> What does <code>r("CODE")</code> return?
- A
EDOR
- B
CDOE
- C
CODE
- Dcheck_circle
EDOC
Explanation
The recursion peels the first character and appends it after the recursive reverse of the rest, producing the reversed string. "CODE" reversed is "EDOC".