Core Java and the Runtime Memory Model: past questions

3 questions · 10 marks · 1 papers. Try each one before checking.

Solve them and check answers →Read the notes first

2026 Jul 16

Question 5 MCQ · 3 marks

Consider the Java code given below.

public class FClass {
    public static void main(String[] args) {
        int i = 0;
        do {
            System.out.println("1 2");
            do {
                System.out.println("3 4");
                i++;
            } while (i < 2);
        } while (i < 3);
    }
}

Choose the correct option regarding the output produced by the code.

  1. 1 2
    3 4
    1 2
    3 4
  2. 1 2
    3 4
    3 4
    3 4
  3. 1 2
    3 4
    3 4
    1 2
    3 4
  4. 1 2
    3 4
    1 2
    3 4
    3 4

Question 6 MCQ · 3 marks

What is the output of the following code?

public class ArrayTest {
    public static int[] update(int[] x) {
        for(int i = 0; i < x.length; i++) {
            x[i] = x[i] + 3;
        }
        return x;
    }
    public static void main(String[] args) {
        int[] a = {2, 4, 6, 8};
        int[] b = update(a);
        System.out.println(a[2] + b[2]);
    }
}
  1. 12

  2. 18

  3. 9

  4. 15

Question 1 MSQ · 4 marks

Which of the following statement(s) is/are true regarding activation records used during function calls?

  1. An activation record is removed from the stack immediately after a local variable is declared.

  2. Local variables of a function are typically stored inside its activation record.

  3. A return address is stored in the activation record so that control can return to the caller after the execution of the called function.

  4. All activation records in the stack correspond only to recursive function calls.

  5. When a function calls another function, the control link in the callee's activation record points to the activation record of the caller.

Check your answers →

Weeks covering this topic

Other Java topics