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