What will be the output of the following Java program?

class A 
  {
   int i;
   int j;
       A() 
       {
           i = 1;
           j = 2;
       }
  }
  class Output 
  {
       public static void main(String args[])
       {
            A obj1 = new A();
            A obj2 = new A();
        System.out.print(obj1.equals(obj2));
       }
  }

a) false
b) true
c) 1
d) Compilation Error

1 thought on “What will be the output of the following Java program?”

  1. a
    Explanation: 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:
    $ javac Output.java
    $ java Output
    false

Leave a Comment