Question: Given the following code, match what is exactly printed at each line. public class M 1 P 1 { public static string m 1 (

Given the following code, match what is exactly printed at each line.
public class M1P1{
public static string m1(string str(
if (str. length ()==0)
return "'";
char c= str. charAt();
if (c=='x')
return ' str.substring(1));
}
else return .substring(1));
public static void main(String args[]){
//Line 1 of output
System.out.println(m1("Bob")+1);
//Line 2 of output
System, out.println(m1("Fox")+2);
//Line 3 of output
System.out.println(m1("Trix are for young kids")+3);
//Line 4 of output
system.out.println(m1("")+4);
}
]
}.
}
Line 1
Line 2
Line 3
Line 4
 Given the following code, match what is exactly printed at each

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!