Given the following method: public void bbb(String s, int p) { if (p >= 0) { Sys
ID: 3608265 • Letter: G
Question
Given the following method: public void bbb(String s, int p) { if (p >= 0) { System.out.print(s.charAt(p)); bbb(s, p - 1); } } What will the output be if the call isbbb("January", 4); ? _____________________________ Given the following method: public void bbb(String s, int p) { if (p >= 0) { System.out.print(s.charAt(p)); bbb(s, p - 1); } } What will the output be if the call isbbb("January", 4); ? _____________________________Explanation / Answer
Output will be
aunaJ
here is the trace of callingabove function.
Callingbbb(January,4) Since p >=0 so it willprint char of string January at position 4 = a and will callbbb(s,p-1) aCallingbbb(January,3) Since p >=0 so it willprint char of string January at position 3 = u and will callbbb(s,p-1) uCallingbbb(January,2) Since p >=0 so it willprint char of string January at position 2 = n and will callbbb(s,p-1) nCallingbbb(January,1) Since p >=0 so it willprint char of string January at position 1 = a and will callbbb(s,p-1) aCallingbbb(January,0) Since p >=0 so it willprint char of string January at position 0 = J and will callbbb(s,p-1) JCallingbbb(January,-1) Callingbbb(January,4) Since p >=0 so it willprint char of string January at position 4 = a and will callbbb(s,p-1) aCallingbbb(January,3) Since p >=0 so it willprint char of string January at position 3 = u and will callbbb(s,p-1) uCallingbbb(January,2) Since p >=0 so it willprint char of string January at position 2 = n and will callbbb(s,p-1) nCallingbbb(January,1) Since p >=0 so it willprint char of string January at position 1 = a and will callbbb(s,p-1) aCallingbbb(January,0) Since p >=0 so it willprint char of string January at position 0 = J and will callbbb(s,p-1) JCallingbbb(January,-1)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.