| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice TestPractice Test
About Exam
medium Solved by 7 students
Recursive String Method Trace
< Prev
Next >

Consider the following recursive method.

public static void whatsItDo(String str)
{
    int len = str.length();
    if (len > 1)
    {
        String temp = str.substring(0, len - 1);
        whatsItDo(temp);
        System.out.println(temp);
    }
}

What is printed as a result of the call whatsItDo("BATCH")?

A

BATCH
BATC
BAT
BA
B
BA
BAT
BATC
BATCH

B

BATC
BAT
BA
B

C

BATCH
BATC
BAT
BA

D

B
BA
BAT
BATC

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
#1ethan22 1m 04s 136
#2songqiuhui201201 0m 25s -35
#3singhris00002 2m 35s -175
#4upadhgau00001 2m 52s -182
#5gorkemakyuz20107501 3m 06s -196
#6suhanakochhar00613 5m 24s -244
#7psak1212 8m 22s -412
#8richa.tuli23 13m 05s -595
Items per page:
10
1 – 8 of 8
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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