Question: Today, you will use features of Reflection in Java programming language to examine and manipulate internal properties of the library program written in the previous

Today, you will use features of Reflection in Java programming language to examine and manipulate internal properties of the library program written in the previous labs (use the first version
without subsequent modifications).
Create an object of Class for the Book class created during the last lab, using forName()
method which takes the name of the class to be reflected as its argument. Create it also using
getClass() method and .class extension. You will use this object to get information about the
corresponding class at runtime. Using object of the getClass() get and print all the declared
methods of Book. To this end, create an object of the Method class, looping over all declared
methods, get names of methods, get the access modifier of methods and get the return types for
each method.
Add the private field pagesNr to the Book class and set its default value as 100. Use Reflection
to get and to modify the value of this private field. Likewisely with methods, list and inspect all
the fields with their access modifiers in the Book class.
Get the superclass for Book class, using Reflection, and inspect all methods and fields of the
superclass.
Add the private constructor and the public constructor for the Book class with different number
of arguments as the original constructor. The constructurs should set some arguments with default
values, while leaving the others, you can add some extra fields to the class. Using Reflection, find
the information about the constructors of the class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!