Question 8909 – Structure
March 19, 2024Question 16253 – UGC NET Dec-2020 and June-2021 Paper-2
March 19, 2024Question 16248 – UGC NET Dec-2020 and June-2021 Paper-2
Consider the following recursive function F() in Java that takes an integer value and returns a string value:
public static String F( int N ) {
if ( N < = 0) return “-“;
return F(N – 3) + N + F(N – 2) + N;
}
The value of F(5) is:
Correct Answer: C
Question 28 Explanation:
F(1) return the value -1-1
F(2) return the value -2-2
F(3) return the value -3-1-13
F(4) return the value -1-14-2-24
F(5) return the value -2-25-3-1-135
F(2) return the value -2-2
F(3) return the value -3-1-13
F(4) return the value -1-14-2-24
F(5) return the value -2-25-3-1-135
-1-145-2-245
-2-25-1-3-135
-2-25-3-1-135
-2-25-3-135
Subscribe
Login
0 Comments