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: 69% (13 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...
-
What does the difference between the totals of the Income Statement columns represent? What does the difference between the Balance Sheet column totals represent?
-
Identify documents to store in home files, safe-deposit boxes, or on a computer.
-
Mike Greenberg opened Clean Window Washing Inc. on July 1, 2014. During July, the following transactions were completed. July 1 Issued 12,000 shares of common stock for $12,000 cash. 1 Purchased used...
-
Choose a company that has a Web site. By exploring the Web site, determine the goals of the company. How does the company use the Internet to accomplish these goals? Report your findings in two...
-
A motor supplies a moment M to the pulley of radius R1. A belt connects this pulley to pulley A. Pulleys A and B form a rigid body with a common hub. Ignore the inertias of the three pulleys....
-
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...
-
On June 17, 2023, Bishop agrees to invest $30,000 into an online custom T-shirt print shop business for a 40% interest in total partnership equity. At the time Bishop is admitted, the existing...
-
On the first day of the current fiscal year, $2,000,000 of 10-year, 7% bonds, with interest payable semiannually, were sold for $2,125,000. Journalize the following transactions for the current...
-
Two charges A and B of magnitudes +8.0 C each, are kept at points (2,1) and (2,7) respectively in a Cartesian coordinate system measured in meters. If the charges are in a vacuum, calculate the force...
-
Can you elaborate on the strategic significance of dynamic capabilities in enabling organizations to sense, seize, and reconfigure resources and competencies in response to evolving market conditions...
-
A wave with the following deep-water characteristics is propagating toward the shore in an area where the bottom contours are all straight and parallel to the coastline: Ho=3m, T= 10s The bottom is...
-
Sultan Company uses an activity-based costing system. At the beginning of the year, the company made the following estimates of cost and activity for its five activity cost pools: Activity Cost Pool...
-
How can a higher-level manager avoid the problem of filtering when lower-level staffers pass information upward to her?
-
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...
-
Question 66 of 75. All of the following are recorded on Schedule C, Profit or Loss from Business, EXCEPT: 0000 Expenses paid during the year. Gross receipts. Information on the taxpayer's vehicle....
-
When Tom's income decreases, he purchases more hamburgers. We can conclude that for Tom, hamburger is a ( n ) _ _ _ _ _ _ _ _ good. substitute complementary normal inferior
-
Incoterms clearly state which tasks, risks and _ _ _ _ _ _ _ _ are associated with the buyer and which are with the seller. A . Profits B . Costs C . Quantity of goods D . Quality of goods
Study smarter with the SolutionInn App