Object o1 = new Object(); Object o2 = new Object(); //o1=o2; System.out.println(o1.equals(o2));
It returns false. It can return true
false
true
equals method needs to be overridden inside the class if you want to make it behave in some other way. By default, it checks if two references refer to the same object.