Given the code below, what will be the output of the println…
Given the code below, what will be the output of the println(…) invocation shown? public static String recurse(String name, int index) { if(index >= name.length()) return “”; else { switch(name.charAt(index)) { case ‘a’: return “naps ” + recurse(“pans”, index+1); case ‘n’: return “pans ” + recurse(“snap”, index+1); case ‘p’: return “snap ” + recurse(“span”, index+1); default: return “oops ” + recurse(name, index+1); } }} System.out.println( recurse(“night”, 0) );
Read Details