

InterviewSolution
Saved Bookmarks
1. |
The following functions numbers (int) and numbers1 (int) are a part of some class. Answer the questions given below showing the dry run/working:public void numbers (int n) { if (n > 0) { System.out. print(n + " " ); numbers (n-2); System.out.print(n + " "); } } public String numbers1 (int n) { if (n < = 0) return " "; return numbersl(n-1) + n + " "; }(i) What will be the output of the function numbers (int n) when n = 5?(ii) What will the function numbersl (int n) return when n = 6? (iii) State in one line what is the function numbersl (int) doing apart from recursion? |
Answer» (i) 5 3 1 1 3 5 (ii) “1 2 3 4 5 6” (iii) It display all number from 1 to that number. |
|