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

    class equal
    {
    int p;
    int q;
    boolean isequal()
    {
    return(p == q);
    }
    }
    public class Result
    {
    public static void main(String args[])
    {
    equal obj = new equal();
    obj.p = 7;
    obj.q = 10;
    System.out.println(obj.isequal());
    }
    }
    1. Compiletime error
    2. false
    3. Runtime error
    4. true
    5. None of these
Correct Option: B

Output: false



Your comments will be displayed only after manual approval.