Which method(s) would produce the following output if they were passed the parameter, "hamster"?
hamster
hamste
hamst
hams
ham
ha
h
I.
public static void mystery(String wo) {
System.out.println(wo);
if (wo.length() > 0)
mystery( wo.substring(0, wo.length() - 1));
}
II.
public static void mystery(String wo) {
if (wo.length() > 0)
mystery( wo.substring(0, wo.length() - 1));
System.out.println(wo);
}
III.
public static void mystery(String wo) {
if (wo.length() > 0)
mystery( wo.substring( wo.length() - 1));
System.out.println(wo);
}
1. I, II and III
2. I only
3. I and III only
4. II only
5. III only