//1. Write out the output for eaching of following: /* Consider this function. void myMethod( int counter) { if(counter == 0) return; else { System.out.println(""+counter); myMethod(--counter); return; } }
function myMethod(int counter) will print the number starting from counter value till 1. at each recursive call counter value is decremented by 1. When counter value reaches 0, the function ends beacuse of if condition where it checks if counter is 0 then return from method and control goes back to main method.
code:-
Ouput
Get Answers For Free
Most questions answered within 1 hours.