### Question:
Unit implements Serializable { private Unit() {} private  Unit(); static Unit unit(); @Override String toString();  }### Answer:
@Test public void onlyOneInstance() { assertSame(Unit.unit(), Unit.unit()); }
@Test public void serializable() throws IOException, ClassNotFoundException { Unit unit = Unit.unit(); byte[] bytes; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos);) { out.writeObject(unit); out.flush(); bytes = baos.toByteArray(); } Object result; try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes))) { result = in.readObject(); } assertSame(unit, result); }