Hello ,
this question is from k& b book form topic 7 Generics and collection qs no 7 , can some one explain the flow of this i am not getting
import java.util.*;
class MapEQ
{
public static void main(
String[] args)
{
Map<ToDos , String > m = new HashMap<ToDos , String>();
ToDos t1 = new ToDos("Monday");
ToDos t2 = new ToDos("Monday");
ToDos t3 = new ToDos("Tuesday");
m.put(t1 , "doLaundry");
m.put(t2 , "payBills");
m.put(t3 , "cleanAttic");
}
}
class ToDos {
String day;
ToDos(String d )
{
day = d;
}
public boolean equals(Object o) {
return((ToDos)o).day==this.day'
}
// public int hashCode()
{
return 9;
}
}
o/p
a. As the code stands it will not compile
b. As the code stands the output will be 2
c. As the code stands the output will be 3
d. if the hshCode() method is uncommented the output will be 2
e. if the hshCode() method is uncommented the output will be 3
f. if the hshCode() method is uncommented code s will not compile
c and d are the right options of this question
thanks in advance