### Question:
UI extends QBeanSupport implements UIObjectFactory { public Object newInstance (String clazz) throws Exception { return getFactory().newInstance (clazz); } UI(); void startService(); void stopService(); Object newInstance(String clazz);  }### Answer:
@Test public void testNewInstanceThrowsNullPointerException() throws Throwable { try { new UI().newInstance("testUIClazz"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.q2.Q2.getFactory()\" because the return value of \"org.jpos.q2.QBeanSupport.getServer()\" is null", ex.getMessage(), "ex.getMessage()"); } } }