### Question:
SafeCast { public static short[] toShortArray(Object o, short[] def) { if (!(o instanceof short[])) { return def; } return (short[]) 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 testShortArray() { short[] array = new short[10]; short[] backup = new short[10]; assertTrue("Unable to process valid cast", SafeCast.toShortArray(array, backup) == array); assertTrue("Default did not work (wrong type)", SafeCast.toShortArray(new Integer(22), backup) == backup); assertTrue("Default did not work (null)", SafeCast.toShortArray(null, backup) == backup); }