Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started