### Question:
HashMap extends Map<K, V> { @Override public Set<K> keySet() { if (keysSet == null) keysSet = new KeySet<K, V>(this); return keysSet; } 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 testKeySet() { Set<Object> s = hm.keySet(); assertTrue("Returned set of incorrect size()", s.size() == hm.size()); for (int i = 0; i < objArray.length; i++) { assertTrue("Returned set does not contain all keys", s.contains(objArray[i].toString())); } Map<Integer, String> map = new HashMap<Integer, String>(101); map.put(1, "1"); map.put(102, "102"); map.put(203, "203"); Iterator<Integer> it = map.keySet().iterator(); Integer remove1 = it.next(); it.hasNext(); it.remove(); Integer remove2 = it.next(); it.remove(); ArrayList<Integer> list = new ArrayList<Integer>(1, 102, 203); list.remove(remove1); list.remove(remove2); assertEquals(it.next(), list.get(0)); assertEquals("Wrong size", 1, map.size()); assertTrue("Wrong contents", map.keySet().iterator().next().equals(list.get(0))); Map<Integer, String> map2 = new HashMap<Integer, String>(101); map2.put(1, "1"); map2.put(4, "4"); Iterator<Integer> it2 = map2.keySet().iterator(); int remove3 = it2.next(); int next; if (remove3 == 1) next = 4; else next = 1; it2.hasNext(); it2.remove(); assertTrue("Wrong result 2", it2.next() == next); assertEquals("Wrong size 2", 1, map2.size()); assertTrue("Wrong contents 2", map2.keySet().iterator().next() == next); }