Recursive String Method Trace
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
false
D
true
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | richa.tuli | 2 | 3 | 3m 42s | -32 |
| #2 | suhanakochhar006 | 1 | 1 | 3m 21s | -101 |
| #3 | singhris000 | 1 | 4 | 3m 45s | -155 |
APFIVE