Question: Given the following code, which argument ( s ) will cause the method to return true? public static boolean isIdeal ( String s ) {

Given the following code, which argument(s) will cause the method to return true?
public static boolean isIdeal(String s)
{
int low =0;
int high = s.length()-1;
while (low < high)
{
if (s.charAt(low)!= s.charAt(high))
{
return false;
}
low++;
high--;
}
return true;
}
I. isIdeal("civic")
II. isIdeal("level")
III. isIdeal("race car")
IV. isIdeal("rotor")
Question 7 options:
I, II, and III only
I, II, and IV only
I only
I and II only

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!