### Question:
Classes { public static <T> T instantiate(Class<T> clazz) { try { return clazz .getConstructor() .newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException( String.format("Cannot instantiate %s", clazz.getName()), e); } } private  Classes(); static T instantiate(Class<T> clazz);  }### Answer:
@Test public void testInstantiate() { assertThat(Classes.instantiate(NoArg.class), is(instanceOf(NoArg.class))); }
@Test public void testInstantiate_NoNoArgs() { Assertions.assertThrows(IllegalArgumentException.class, () -> { Classes.instantiate(WithArg.class); }); }
@Test public void testInstantiate_PrivateConstructor() { Assertions.assertThrows(IllegalArgumentException.class, () -> { Classes.instantiate(PrivateConstructor.class); }); }