Hi,
in the following question,b1.equals(b2) is true because, the Boolean class overrides the 'equals' method of Object class.
Can anybody tell me what are the other classes which overrides the equals method, and produces such results.(Apart from
String and Wrapper classes)
Question : What is written to the standard output as the result of executing the following statements?
Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean(true);
Object obj1 = (Object)b1;
Object obj2 = (Object)b2;
if (obj1 == obj2)
if (obj1.equals(obj2))
System.out.println("a");
else
System.out.println("b");
else
if (obj1.equals(obj2))
System.out.println("c");
else
System.out.println("d");
Select the one right answer.
a) a
b) b
c) c
d) d