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

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

Output: 15



Your comments will be displayed only after manual approval.