Limited access

Upgrade to access all content for this subject

Consider the following class.

public class StringMania 
{
    private String str;

    public StringMania(String s)
    {
        str = s;
    }

    public int stringGymnastics(String s1, int a)
    {
        if (str.indexOf(s1)>=0)
            if (a>str.indexOf(s1))
                return a;
            else
                return str.indexOf(s1);
        else
            return a*-1;
    }

    public String stringGymnastics(int a)
    {
        if (a<str.length())
            return str.substring(a);
        else
        if (str.length()>0)
            return str.substring(str.length()-1);
        else
            return null;
    }

    public String stringGymnastics(int a, int b)
    {
        if (a>0 && a<b && b<=str.length())
            return str.substring(a,b);
        else
        if (str.length()>0 && a>=0 && a<str.length())
            return str.substring(a);
        else
            return "no";
    }
}

Consider the following code segment.

StringMania mania = new StringMania("kilometer");
System.out.print(mania.stringGymnastics(10) + " ");
System.out.print(mania.stringGymnastics("me", 3) + " ");
System.out.println(mania.stringGymnastics(5,8));

What is output to the console when this segment of code is executed?

A
r 3 eter
B
r -3 eter
C
null 4 eter
D
r 4 eter
E
r 4 ete
Select an assignment template