| 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 boolean isNestedProperly(String s) {
  if (s.isEmpty())
    return true;
  else if (s.charAt(0) == 'x' && s.charAt(s.length() - 1) == 'x')
    return isNestedProperly(s.substring(1, s.length() - 1));
  else
    return false;
}

What is returned as a result of the call isNestedProperly("xxxx")?

A

The function returns nothing; there is a compilation error

B

The function throws an exception

C

true

D

false

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
#1richa.tuli23 3m 42s -32
#2suhanakochhar00611 3m 21s -101
#3singhris00014 3m 45s -155
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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