Consider the following methods. // Pre-condition: s has at least 2 characters pu
ID: 3727984 • Letter: C
Question
Consider the following methods. // Pre-condition: s has at least 2 characters public static void insaneString(String s) nt count; for (int 1; i1) totallyAbsurdstring(s.substring(s.length()-2) + s); // Pre-condition: s has at least 2 characters public static void totallyAbsurdstring(String s) if (s.substring(0,1).equals (s.substring(s.Length)-1))) insaneString(s.substring(s. Length )-1)+); else System.out.println (s); What is output to the console when this segment of code is executed? totallyAbsurdString("stars")Explanation / Answer
Answer: rssstars
The above code will execute and print the output like "rssstars"
In totallyAbsurdString method, we are checking first and last chars in the string same or not. if same, then we are making call o insaneString mathd, else displaying the final string.