Multiple Choice
Example Code Ch 12-4
The following recursive method recognizes whether a String parameter consists of a specific pattern and returns true if the String has that pattern, false otherwise.
public boolean patternRecognizer(String a)
{
if (a == null) return false;
else if (a.length() == 1 || (a.length() == 2
&& a.charAt(0) == a.charAt(1) ) )
return true;
else if )
return false;
else if )
return patternRecognizer) ;
else return false;
}
-Refer to Example Code Ch 12-4: If the method is called as patternRecognizer(x) where x = "aa", what will the result be?
A) true
B) false
C) NullPointerException
D) a run-time error
E) infinite recursion
Correct Answer:

Verified
Correct Answer:
Verified
Q19: Some problems are easier to solve recursively
Q20: Rewrite the following iterative method as a
Q21: The game of high-low is one where
Q22: Example Code Ch 12-2<br>Given the following recursive
Q23: Example Code Ch 12-4<br>The following recursive method
Q25: Provide a definition for the following terms
Q26: Example Code Ch 12-2<br>Given the following recursive
Q27: Rewrite the following iterative method as a
Q28: Demonstrate how factorial(4) is computed given the
Q29: Recall the Towers of Hanoi recursive solution