JAVA Reflection mechanism Exercises __java

Source: Internet
Author: User
Tags reflection

1. Suppose the tester class has the following test method:
public int test (int p1, Integer p2)
Which of the following code can correctly dynamically invoke the test method of a Tester object. (radio)
A
Class Classtype=tester.class;
Object tester=classtype.newinstance ();
Method Addmethod=classtype.getmethod ("Test", New Class[]{int.class,int.class});
Object Result=addmethod.invoke (Tester,
New Object[]{new Integer (m), new Integer (200)});
B
Class Classtype=tester.class;
Object tester=classtype.newinstance ();
Method Addmethod=classtype.getmethod ("Test", New Class[]{int.class,int.class});
int Result=addmethod.invoke (tester,
New Object[]{new Integer (m), new Integer (200)});

C
Class Classtype=tester.class;
Object tester=classtype.newinstance ();
Method Addmethod=classtype.getmethod ("Test", New Class[]{int.class,integer.class});
Object Result=addmethod.invoke (Tester,
New Object[]{new Integer (m), new Integer (200)});
D
Class Classtype=tester.class;
Object tester=classtype.newinstance ();
Method Addmethod=classtype.getmethod ("Test", New Class[]{int.class,integer.class});
Integer Result=addmethod.invoke (Tester,
New Object[]{new Integer (m), new Integer (200)});
2. Which of the following methods is defined in the class class. (Multiple selection)
A GetConstructors () B. Getprivatemethods () C. Getdeclaredfields ()
D Getimports () E. SetField ()
3. Which of the following statements is true? (Multiple selection)
A Dynamic proxy classes, like static proxy classes, must be written by developers and compiled
into a. class file
B The proxy class has the same interface as the proxy class
C The Java.lang.Exception class implements the Java.io.Serializable interface, so the exception object
Can be serialized and transmitted over the network
D The proxy class in the Java.lang.reflect package provides a way to create a dynamic proxy class
4. Which of the following is characteristic of the dynamic proxy class. (Multiple selection)
A Dynamic proxy classes are public, final, and non-abstract types.
B The dynamic proxy class inherits the Java.lang.reflect.Proxy class
C The dynamic proxy class implements the parameters in the Getproxyclass () or Newproxyinstance () method
Interfaces all interfaces specified by
D Dynamic proxy classes can inherit any user-defined classes
E. Dynamic proxy classes have a constructed method of the public type, which has a
Parameters for Invocationhandler type
5. In the example described in Section 10.3.3 of this chapter (using the proxy class in the remote Method invocation), Connector
Class is on the server side or the client. (radio)
A Server-side B. Client
6. In the example described in Section 10.3.3 of this chapter (using proxy classes in remote method calls),
The Helloserviceproxy class is located on the server side or the client. (radio)
A Server-side B. Client
Answer: 1. C 2. AC 3. BCD 4. ABCE 5. B  6. B

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.