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

    class calclution
    {
    int p;
    int q;
    calclution(int K, int L)
    {
    p = K;
    q = L;
    }
    void calc(calclution n)
    {
    n.p *= 2;
    n.p /= 2;
    }
    }
    public class Result
    {
    public static void main(String args[])
    {
    calclution obj = new calclution(50 , 20);
    obj.calc(obj);
    System.out.println(obj.p + " " + obj.q);
    }
    }
    1. 20 30
    2. 50 20
    3. 40 10
    4. 20 50
    5. 10 10
Correct Option: B

Output: 50 20



Your comments will be displayed only after manual approval.