### Question:
TypedList implements List<Object> { public Object set(int index, Object element) { return inner.set(index, convertToTypedObject(element)); } TypedList(final ListType type);  TypedList(final ListType type,
            final Collection<? extends Object> collection); @SuppressWarnings("unchecked")  TypedList(final ListType type, final Object array); ListType getType(); Type getElementType(); void add(int index, Object element); boolean add(Object o); boolean addAll(Collection<? extends Object> c); boolean addAll(int index, Collection<? extends Object> c); void clear(); boolean contains(Object o); boolean containsAll(Collection<?> c); Object get(int index); int indexOf(Object o); boolean isEmpty(); Iterator<Object> iterator(); int lastIndexOf(Object o); ListIterator<Object> listIterator(); ListIterator<Object> listIterator(int index); Object remove(int index); boolean remove(Object o); boolean removeAll(Collection<?> c); boolean retainAll(Collection<?> c); Object set(int index, Object element); int size(); List<Object> subList(int fromIndex, int toIndex); Object[] toArray(); T[] toArray(T[] a); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void testSet() throws Exception { String[] strings = new String[] { "a", "b", "c", null, "a", "b", "c", "d" }; List<Object> list = new TypedList(stringListType, strings); assertEquals(strings[4], list.set(4, "e")); assertEquals(strings.length, list.size()); assertEquals("a", list.get(0)); assertEquals("b", list.get(1)); assertEquals("c", list.get(2)); assertEquals(null, list.get(3)); assertEquals("e", list.get(4)); assertEquals("b", list.get(5)); assertEquals("c", list.get(6)); assertEquals("d", list.get(7)); assertEquals(strings[0], list.set(0, null)); assertEquals(strings.length, list.size()); assertEquals(null, list.get(0)); assertEquals("b", list.get(1)); assertEquals("c", list.get(2)); assertEquals(null, list.get(3)); assertEquals("e", list.get(4)); assertEquals("b", list.get(5)); assertEquals("c", list.get(6)); assertEquals("d", list.get(7)); try { list.set(0, 1); fail(); } catch (UnassignableValueException e) { } try { list.set(-1, "a"); fail(); } catch (IndexOutOfBoundsException e) { } try { list.set(list.size(), "a"); fail(); } catch (IndexOutOfBoundsException e) { } }