Java reflection mechanism exercise questions

Source: Internet
Author: User

1. Assume that the tester class has the following test method:
Public int test (INT P1, integer P2)
Which of the following code correctly and dynamically calls the test method of a tester object? (Single choice)
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 (100), 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 (100), 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 (100), 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 (100), new INTEGER (200 )});
2. Which of the following methods are defined in the class? (Multiple options)
A. getconstructors () B. getprivatemethods () C. getdeclaredfields ()
D. getimports () E. setfield ()
3. Which of the following statements are true? (Multiple options)
A. The dynamic proxy class is the same as the static proxy class. The source code must be compiled and compiled by the developer.
. Class File
B. The proxy class has the same interface as the proxy class.
C. java. Lang. exception class implements the java. Io. serializable interface, so the exception object
Can be serialized and transmitted over the network
The proxy class in the D. java. Lang. Reflect package provides a method to create a dynamic proxy class.
4. Which of the following are the characteristics of dynamic proxy? (Multiple options)
A. The dynamic proxy class is public, final, and non-abstract.
B. The dynamic proxy class inherits the java. Lang. Reflect. proxy class.
C. The dynamic proxy class implements parameters in the getproxyclass () or newproxyinstance () method.
All interfaces specified by interfaces
D. The dynamic proxy class can inherit any custom class.
E. Dynamic proxy classes all have a public constructor. This constructor has
Invocationhandler Parameters
5. In the example described in section 10.3.3 of this chapter (using proxy classes in remote method calls), Connector
Is the class on the server or client? (Single choice)
A. Server B. Client
6. In the example described in section 10.3.3 of this chapter (using proxy classes in remote method calls,
Is the helloserviceproxy class on the server or client? (Single choice)
A. Server B. Client
7. Use the dynamic proxy mechanism introduced in this chapter to re-implement the echoserver and
For more information about the implementation methods of echoclient, see section 10.3.3 (using proxy classes in remote method calls) in this chapter.
Example.
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.