题目内容

8、以下代码运行的结果是()。import java.lang.reflect.*;public class Person {public String eat(Integer num, String food ) {System.out.print("吃" + num + "个" + food + " ");return food;}public static void main(String[] args) throws Exception {Class clazz = Person.class;Person p = (Person) clazz.newInstance();Method method = clazz.getMethod("eat", Integer.class, String.class);Class type = method.getReturnType();method.invoke(p, 1, "苹果");System.out.print(type.getSimpleName() + " ");System.out.print(method.getGenericParameterTypes()[1] instanceof Class);}}

A. 吃1个苹果 java.lang.String true
B. 吃1个苹果 String true
C. 吃1个苹果 java.lang.String false
D. 吃1个苹果 String false

查看答案
更多问题

3、(多选题)假定Tester类:Class classType = Tester.class;Constructor constructor = classType.getConstructor();以下能正确构造一个Tester对象的是()。

A. Class.newInstance();
B. constructor.newInstance();
C. Tester.newInstance();
D. classType.newInstance();

3、获取一个类的Class对象后,可以实现类的动态代理、获取父类的泛型类型、获取当前类实现的接口等操作。

A. 对
B. 错

5、以下代码可以使用反射来检索的是()。@Retention( RetentionPolicy.RUNTIME )public @interface Description{String value;}

A. 对
B. 错

----Staring an email----Hairuddin Omar, a maths teacher, has written four emails this morning. Read the opening lines of the emails and then match them to the descriptions of the emails below.

答案查题题库