Extend the code of Figure 16.4 to print information about (a) Fields (b) Constructors (c) Nested classes
Question:
Extend the code of Figure 16.4 to print information about
(a) Fields
(b) Constructors
(c) Nested classes
(d) Implemented interfaces
(e) Ancestor classes, and their methods, fields, and constructors
(f) Exceptions thrown by methods
(g) Generic type parameters
Figure 16.4:
Transcribed Image Text:
import static java.lang.System.out; public static void listMethods (String s) throws java.lang.ClassNotFoundException { Class c = Class.forName (s); for (Method m : c.getDeclaredMethods ()) { out.print (Modifier.toString (m.getModifiers ()) + " "); out .print (m.getReturnType ().getName () + " "); out.print (m.getName () + "("); // throws if class not found boolean first = true; for (Class p : m.getParameterTypes ()) { if (!first) out.print (", "); first = false; out.print (p.getName ()); out.println(") "); Sample output for listMethods ("java.lang.reflect.Accessible0bject"): public java.lang.annotation. Annotation getAnnotation (java.lang.Class) public boolean isAnnotationPresent (java.lang.Class) public [Ljava.lang.annotation. Annotation; getAnnotations () public [Ljava.lang.annotation. Annotation; getDeclaredAnnotations () public static void setAccessible( [Ljava.lang.reflect. Accessible0bject;, boolean) public void setAccessible (boolean) private static void setAccessible0(java.lang.reflect.Accessible0bject, boolean) public boolean isAccessible ()
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (12 reviews)
ANSWER import static javalangSystemout public static void listMethods String s throws javalangClassNotFoundException Class c ClassforNames throws if c...View the full answer
Answered By
Churchil Mino
I have been a tutor for 2 years and have experience working with students of all ages and abilities. I am comfortable working with students one-on-one or in small groups, and am able to adapt my teaching style to meet the needs of each individual. I am patient and supportive, and my goal is to help my students succeed.
I have a strong background in math and science, and have tutored students in these subjects at all levels, from elementary school to college. I have also helped students prepare for standardized tests such as the SAT and ACT. In addition to academic tutoring, I have also worked as a swim coach and a camp counselor, and have experience working with children with special needs.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Rewrite the code of Figure 7.3 in Ada, Java, or C#. Figure 7.3: template class queue { item items [max_items]; int next_free, next_full, num_items; public: queue () : next_free (0), next_full(0),...
-
Modify the code of Figure 7.3 or your solution to Exercise 7.12 to throw an exception if an attempt is made to enqueue an item in a full queue, or to dequeue an item from an empty queue. Data From...
-
(a) Modify the code of Figure 14.15 (Example 14.35) so that it replaces the form with its output, as the CGI and PHP versions of Figures 14.11 and 14.14 do. (b) Modify the CGI and PHP scripts of...
-
1. differences between debt financing and equity financing 2. accounting differences between preferred stock and common shares. 3. accounting for treasury shares; why do firms want to buy back their...
-
A well-insulated rigid tank contains 6 lbm of saturated liquid-vapor mixture of water at 35 psia. Initially, three-quarters of the mass is in the liquid phase. An electric resistance heater placed in...
-
In problem, x = 0 is a regular singular point of the given differential equation. Show that the indicial roots of the singularity do not differ by an integer. Use the method of Frobenius to obtain...
-
The efficiency of an ideal machine is _____
-
Akers Company sold bonds on July 1, 2017, with a face value of $100,000. These bonds are due in 10 years. The stated annual interest rate is 6% per year, payable semiannually on June 30 and December...
-
To improve the short-range acceleration of an electric car, a capacitor may be used. Charge is stored on the capacitor's surface between a porous composite electrode and electrolytic fluid. Such a...
-
Jimmy owns a garden in which he has planted N trees in a row. After a few years, the trees have grown up and now they have different heights. Jimmy pays much attention to the aesthetics of his...
-
Write an interactive tool that accepts keyboard commands to load specified class files, create instances of their classes, invoke their methods, and read and write their fields. Feel free to limit...
-
Outline mechanisms that might be used by a binary rewriter, without access to source code, to catch uses of uninitialized variables, double deletes, and uses of deallocated memory (e.g., dangling...
-
Which one of the following trends in various economic indicators is most consistent with a recovery from a recession? A. A declining inventorysales ratio and stable industrial production index B. A...
-
a. Why is the term hedge to describe "hedge funds" misleading? b. Where is the term hedge fund described in the U.S. securities laws?
-
What is the source of income for an asset management firm?
-
Some hedge funds will refer to their strategies as "arbitrage strategies." Why would this be misleading?
-
Why is it difficult to determine the cash flow of a financial asset?
-
List three ways the DNP provides leadership in helping a healthcare entity optimize reimbursement from insurers.
-
When an object is located very far away from a convex mirror, the image of the object is 18 cm behind the mirror. Using a ray diagram drawn to scale, determine where the image is located when the...
-
Making use of the tables of atomic masses, find the velocity with which the products of the reaction B10 (n, ) Li7 come apart; the reaction proceeds via interaction of very slow neutrons with...
-
What is the minimum number of bits in a PN sequence if we use FHSS with a channel bandwidth of B = 4 KHz and Bss = 100 KHz?
-
Answer the following questions about the digital hierarchy in Figure 6.23: a. What is the overhead (number of extra bits) in the DS-1 service? b. What is the overhead (number of extra bits) in the...
-
Figure 6.35 shows a demultiplexer in a synchronous TDM. If the input slot is 16 bits long (no framing bits), what is the bit stream in each output? The bits arrive at the demultiplexer as shown by...
-
How crucial is it to understand the many sorts of speech contexts on a daily basis? Give one specific example. Here are the types of speech context: 1. Public Communication 2. Small Group...
-
Enmebaragesi of Kish, Inc. has sales of $282,000, cost of goods sold of $206,000, depreciation of $4,200, and interest expense of $22,000. The tax rate is 30.8 percent. What is the times interest...
-
Inkishush and Company has a book value per share of $10.35, earnings per share of $2.23, and a price-earnings ratio of 19.4. What is the market-to-book ratio?
Study smarter with the SolutionInn App