### Question:
SafeCast { public static long toLong(Object o, long def) { if (!(o instanceof Long)) { return def; } return (Long) 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 testLong() { assertTrue("Unable to process valid cast", SafeCast.toLong(new Long(22), 7L) == 22L); assertTrue("Default did not work (wrong type)", SafeCast.toLong(new Integer(22), 7L) == 7L); assertTrue("Default did not work (null)", SafeCast.toLong(null, 9L) == 9L); }