Home » JAVA Programming » Modifier Types » Question
  1. What is the output of this program?

    class static_Access
    {
    static int p;
    static int q;
    void add(int n1, int n2)
    {
    p = n1 + n2;
    q = p + n2;
    }
    }
    public class static_output
    {
    public static void main(String args[])
    {
    static_Access obj1 = new static_Access();
    static_Access obj2 = new static_Access();
    int n1 = 5;
    obj1.add(n1, n1 + 2);
    obj2.add(6, n1);
    System.out.println(obj1.p + " " + obj2.q);
    }
    }
    1. 11 16
    2. 16 11
    3. 17 11
    4. 11 17
    5. None of these
Correct Option: A

Output: 11 16



Your comments will be displayed only after manual approval.