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

    class N
    {
    int K;
    int L;
    N()
    {
    K = 3;
    L = 5;
    }
    }
    public class Result
    {
    public static void main(String args[])
    {
    N obj1 = new N();
    N obj2 = new N();
    System.out.print(obj1.equals(obj2));
    }
    }
    1. true false
    2. false
    3. true
    4. false true
    5. None of these
Correct Option: B

obj1 and obj2 are two different objects. equals() is a method of Object class, Since Object class is superclass of every class it is available to every object.
output:



Your comments will be displayed only after manual approval.