Java SE 7 Programmer II (1Z0-804)
© examsiri.com
Question : 3 of 8
Marks:
+1,
-0
Given:
And this code snippet:
What is the result?
class MyKeys {
 Integer key;
 MyKeys(Integer k) {
  key = k;
 }
 public boolean equals(Object o) {
  return ((MyKeys) o).key == this.key;
 }
}And this code snippet:
Map m = new HashMap();
MyKeys m1 = new MyKeys(1);
MyKeys m2 = new MyKeys(2);
MyKeys m3 = new MyKeys(1);
MyKeys m4 = new MyKeys(new Integer(2));
m.put(m1, "car");
m.put(m2, "boat");
m.put(m3, "plane");
m.put(m4, "bus");
System.out.print(m.size());What is the result?
Go to Question: