### Question:
ReflectionUtils { public static boolean hasMethod(Class<?> targetClass, String methodName, Class... parameterTypes) { try { targetClass.getMethod(methodName, parameterTypes); return true; } catch (NoSuchMethodException e) { return false; } } private  ReflectionUtils(); static Class<T> getClass(String className); static Class<T> getClassOrNull(String className); static T getFieldValue(Object target, String fieldName); static void setFieldValue(Object target, String fieldName, Object value); static Method getMethod(Object target, String methodName, Class... parameterTypes); static boolean hasMethod(Class<?> targetClass, String methodName, Class... parameterTypes); static Method getGetter(Object target, String property); static Method getSetter(Object target, String property, Class<?> parameterType); static T invoke(Object target, Method method, Object... parameters); static T invokeGetter(Object target, String property); static void invokeSetter(Object target, String property, Object parameter); static final String GETTER_PREFIX; static final String SETTER_PREFIX; }### Answer:
@Test public void testHasMethod() { assertTrue(ReflectionUtils.hasMethod(TestObject.class, "getName")); }
@Test public void testHasMethodThrowsReflectionException() { assertFalse(ReflectionUtils.hasMethod(TestObject.class, "unknown")); }