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

    class access_Example
    {
    public int p;
    private int q;
    void calc(int n1, int n2)
    {
    p = n1 + 1;
    q = n2;
    }
    void print()
    {
    System.out.println(+ q);
    }
    }
    public class access_specifier_result
    {
    public static void main(String args[])
    {
    access_Example obj = new access_Example();
    obj.calc(5, 7);
    System.out.println(obj.p);
    obj.print();
    }
    }
    1. 6
      7
    2. 8
      9
    3. 10
      11
    4. 5
      6
    5. 4
      6
Correct Option: A

Output:
6
7



Your comments will be displayed only after manual approval.