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: 63% (11 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 Exercises 5-8, write the if-then form, the converse, the inverse, and the contrapositive for the given statement. A regular polygon is equilateral.
-
Given that \(f(x)=\frac{k}{2^{x}}\) is a probability distribution for a random variable that can take on the values \(x=\) \(0,1,2,3\), and 4 , find \(k\).
-
The following information concerns the adjusting entries to be recorded on November 30, 2014, for RaiLink's year just ended. a. The Office Supplies account started the year with a $4,800 balance....
-
The job of people who work in advertising agency Media departments is to recommend media selection, programming, and plans that are in the best interest of their clients. The media plans they...
-
Landcruisers plus (LP) has operated an online retail store selling off-road truck parts. As the name implies, the firm specializes in parts for the venerable Toyota FJ40 that is known throughout the...
-
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...
-
At points on the curve y = 2x, line segments of length h = y are drawn perpendicular to the xy-plane. Find the area of the surface formed by these perpendiculars from (0, 0) to (3, 23). 0 X 3 2x y =...
-
What can happen if you do not immediately report a stolen bank card to your bank?
-
What is the importance of re-evaluating your investment portfolio regularly?
-
Discussion 1: Student Loans Assignment (Up to 20 Points) A For quite a while the United States Government has been collecting student loan debt from Social Security benefits of retirees because of a...
-
Alternatively, the ABC system tracks and assigns costs to products with cause and effect factors, including volume-based and non-volume-based drivers, and is therefore expected to improve costing...
-
Identify the sentence that uses the apostrophe correctly to form contractions.
-
The following accounts appear in an adjusted trial balance of San Jose Consulting. Indicate whether each account would be reported in the (a) current asset; (b) property, plant, and equipment; (c)...
-
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...
-
Hall & Company issues $ 1 0 0 , 0 0 0 , 0 0 0 in 6 % bonds with detachable warrants of 1 0 warrants for each $ 1 , 0 0 0 bond. The bonds are issued at 9 9 . Record the issuance under the following...
-
Assume that hein acquired Dolan Development last year. Hein recorded the following intangible assets on the date of acquisition: Goodwill: $ 1 , 5 0 0 , 0 0 0 Dolan Development trademark: $ 6 0 0 , 0...
-
What is the total amount of interest that will be paid of the loan is carried to term with no extra payments made building cost 3 3 0 0 0 0 . loan started im Dec 2 0 2 3 worh a 7 . 5 % interest rate...
Study smarter with the SolutionInn App