public class hashtest1 {
public static void main(
String[] args) {
Foo f1= new Foo();
Foo f2=f1;
Foo f3= new Foo();
}
}
Assuming that Foo has correctly implemented hashCode and equals methods, which of the following will always print out "true" ?
Options:
if(f1.equals(f2)) System.out.println("true");
if(f1.hashCode() == f2.hashCode()) System.out.println("true");
if(f1.hashCode() != f3.hashCode()) System.out.println("true");
if(f1 == f2) System.out.println("true");
Can someone explain me the answer for this question?
Thanks,
Jaimesh