### Question:
SafeCast { public static byte toByte(Object o, byte def) { if (!(o instanceof Byte)) { return def; } return (Byte) o; }  static long toLong(Object o, long def); static int toInt(Object o, int def); static byte toByte(Object o, byte def); static float toFloat(Object o, float def); static byte[] toByteArray(Object o, byte[] def); static short[] toShortArray(Object o, short[] def); static int[] toIntArray(Object o, int[] def); static String toString(Object o, String def); static T toGeneric(Object o, U def, Class<T> clazz);  }### Answer:
@Test public void testByte() { assertTrue("Unable to process valid cast", SafeCast.toByte(new Byte((byte) 22), (byte) 7) == (byte) 22); assertTrue("Default did not work (wrong type)", SafeCast.toByte(new Integer(22), (byte) 7) == (byte) 7); assertTrue("Default did not work (null)", SafeCast.toByte(null, (byte) 9) == (byte) 9); }