Solved

A Palindrome Is a Word or Phrase Spelled Which Reads

Question 7

Multiple Choice

A palindrome is a word or phrase spelled which reads the same forward or backward. Consider the following code snippet: public boolean palindrome(String string)
{
Return isPal(string, 0, string.length() - 1) ;
}
Private boolean isPal(String string, int left, int right)
{
If (left >= right)
{
Return true;
}
Else if (string.charAt(left) == string.charAt(right) )
{
Return isPal(string, left + 1, right - 1) ;
}
Else
{
Return false;
}
}
What does the method palindrome return?


A) true
B) false
C) a palindrome not found exception
D) the Boolean value returned from the isPal method

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions