What will the following program print?
public class Main{ public static void main (String [] args){ Object obj1 = new Object (); Object obj2 = obj1; if ( obj1.equals (obj2) ) System.out.println ("true"); else System.out.println ("false"); } }
Select 1 option
Correct Option is : A
Object class's equals () method just checks whether the two references are pointing to the same location or not.
In this case they are pointing to the same location because of obj2 = obj1; so it returns true.