### Question:
HashMap extends Map<K, V> { @Override public V put(K key, V value) { return putImpl(key, value); } HashMap();  HashMap(int capacity);  HashMap(int capacity, float loadFactor);  HashMap(Map<K, V> map); @Override void clear(); @Override boolean containsKey(K key); @Override boolean containsValue(V value); @Override Set<MapEntry<K, V>> entrySet(); @Override V get(K key); @Override boolean isEmpty(); @Override Set<K> keySet(); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> map); @Override V remove(K key); @Override int size(); @Override Collection<V> values();  }### Answer:
@Test public void testMapEntryHashCode() { HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(10); int key = 1; int val = 2; map.put(key, val); int expected = ((Object) key).hashCode() ^ ((Object) val).hashCode(); assertEquals(expected, map.hashCode()); key = 4; val = 8; map.put(key, val); expected += ((Object) key).hashCode() ^ ((Object) val).hashCode(); assertEquals(expected, map.hashCode()); }
@Test public void testPut() { hm.put("KEY", "VALUE"); assertEquals("Failed to install key/value pair", "VALUE", hm.get("KEY")); HashMap<Object, Object> m = new HashMap<Object, Object>(); m.put(0L, "long"); m.put(0, "int"); assertEquals("Failed adding to bucket containing null", "long", m.get(0L)); assertEquals("Failed adding to bucket containing null2", "int", m.get(0)); HashMap<Integer, String> map = new HashMap<Integer, String>(); for (int i = -32767; i < 32768; i++) { map.put(i, "foobar"); } int myKey = 0; map.put(myKey, "myValue"); assertTrue(map.containsKey(myKey)); assertEquals("myValue", map.get(myKey)); assertNotNull(map.remove(myKey)); map.put(myKey, "myValue"); assertTrue(map.containsKey(myKey)); assertEquals("myValue", map.get(myKey)); boolean found = false; for (Iterator<Integer> itr = map.keySet().iterator(); itr.hasNext(); ) { Integer key = itr.next(); if (found = key == myKey) { break; } } assertTrue("Did not find new key instance in hashmap", found); HashMap<Object, Object> objmap = new HashMap<Object, Object>(); for (int i = 0; i < 32768; i++) { objmap.put(i, "foobar"); } MyKey aKey = new MyKey(); assertNull(objmap.put(aKey, "value")); assertNull(objmap.remove(new MyKey())); assertEquals("foobar", objmap.get(0)); assertEquals("value", objmap.get(aKey)); }