### Question:
KeyedObjects implements Cloneable, PublicCloneable, Serializable { public void setObject(Comparable key, Object object) { int keyIndex = getIndex(key); if (keyIndex >= 0) { KeyedObject ko = this.data.get(keyIndex); ko.setObject(object); } else { KeyedObject ko = new KeyedObject(key, object); this.data.add(ko); } } KeyedObjects(); int getItemCount(); Object getObject(int item); Comparable getKey(int index); int getIndex(Comparable key); List<Comparable> getKeys(); Object getObject(Comparable key); void addObject(Comparable key, Object object); void setObject(Comparable key, Object object); void insertValue(int position, Comparable key, Object value); void removeValue(int index); void removeValue(Comparable key); void clear(); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void testSetObject() { KeyedObjects ko1 = new KeyedObjects(); ko1.setObject("Key 1", "Object 1"); ko1.setObject("Key 2", null); ko1.setObject("Key 3", "Object 2"); assertEquals("Object 1", ko1.getObject("Key 1")); assertEquals(null, ko1.getObject("Key 2")); assertEquals("Object 2", ko1.getObject("Key 3")); ko1.setObject("Key 2", "AAA"); ko1.setObject("Key 3", "BBB"); assertEquals("AAA", ko1.getObject("Key 2")); assertEquals("BBB", ko1.getObject("Key 3")); try { ko1.setObject(null, "XX"); fail("Should have thrown IllegalArgumentException on null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'key' argument.", e.getMessage()); } }