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

    class method
    {
    int p;
    int q;
    void add(int n)
    {
    p = n + 2;
    }
    void add(int n, int b)
    {
    p = n + 5;
    }
    }
    public class method_overloading
    {
    public static void main(String args[])
    {
    method obj = new method();
    int n = 0;
    obj.add(10);
    System.out.println(obj.p);
    }
    }
    1. 10
    2. 11
    3. 12
    4. 13
    5. 14
Correct Option: B

Output: 12



Your comments will be displayed only after manual approval.