Consider the following Java program and determine the integer value printed by the execution of the main() method. class Test { static int x = 5…
Consider the following Java program and determine the integer value printed by the execution of the main() method.
class Test {
static int x = 5;
public static int fun(int n) {
if (n <= 1) {
return 1;
}
x = x + 2;
return fun(n - 1) + x;
}
public static void main(String[] args) {
System.out.println(fun(3));
}
}From the Combined Bank Senior Officer July 2026 – Written exam, question 71 of 73.
More from this paper
- Previous: Define the following terms used in tree data structures: (i) Tree, (ii) Leaf Node, (iii) Internal Node, and (iv) Height of a Tree. Provide…
- Next: An array contains one million sorted integers. Which searching algorithm would you choose to find a given element? Justify your answer.
- All questions in Combined Bank Senior Officer July 2026 – Written