Page 1 :
Wednesday, January 12, 2022, 8:07 PM, , COMBINED ISC 135 Page 1
Page 3 :
(a) 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 numbers1(n-1) + n + " ";, }, (i) What will be the output of the function numbers (int n) when n = 5? [2], (ii) What will the function numbersl (int n) return when n = 6? [2], (iii) State in one line what is the function numbersl (int) doing apart from, recursion? [1], , The following is a part of some class. What will be the output of, the function mymethod( ) when the value of the counter is equal, to 3? Show the dry run/working. [5], , void mymethod (int counter), {, if (counter == 0), System.out. println(” ");, else, {, System.out.println ("Hello" +counter);, mymethod (--counter);, System.out.println (" " +counter);, }, }, , The following function Mystery( ) is a part of some class., What will the function Mystery( ) return when the value of, num=43629, x=3 and y=4 respectively? Show the dry, run/working. [5], , int Mystery (int num, int x, int y), {, if(num<10), , COMBINED ISC 135 Page 3
Page 4 :
return num;, else, {, int z = num % 10;, if(z%2 == 0), return z*x + Mystery (num/10, x, y);, else, return z*y + Mystery(num/10, x, y);, }, }, , COMBINED ISC 135 Page 4