| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice TestPractice Test
About Exam
easy
Recursive String Method Output
< Prev
Next >

Consider the following recursive method. What is printed as a result of the call processString(input)?

public void processString(String input) 
{
 if (input.length() > 0)
 {
 System.out.print(input.substring(0, 1) + input.substring(0, 1));
 processString(input.substring(1));
 }
}
A

It prints input in reverse order, duplicating each character.

B

It removes every second character in input.

C

It duplicates each character in input.

D

It prints the first character of input twice.

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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