Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

May be a continuation of this: https://www.chegg.com/homework-help/questions-and-answers/111-disecting-objects-method-disect-string-classname-accepts-full-classname-example-domain-q107240012 11.2 Creating objects from thin air The method create(String className) accepts a full classname, and creates a new

image text in transcribed

May be a continuation of this: https://www.chegg.com/homework-help/questions-and-answers/111-disecting-objects-method-disect-string-classname-accepts-full-classname-example-domain-q107240012

11.2 Creating objects from thin air The method create(String className) accepts a full classname, and creates a new object for that class, using reflection classes to do so. You should not assume knowing what classnames will be passed, so hard coding a classname is not allowed. The created object is returned. In order to create an object, this method will use the constructor using the largest number of parameters, and adds random data to that. Example one is creating a new Address object. Address uses ints and Strings in its constructors, so the create method invokes the constructor having six parameters, using random data. Example two is creating a Customer object. A Customer also has an Address, so the create method calls itself again to get an Address object. Creating objects this way will inevitably have exceptions, such as SecurityException and IllegalArgumentException. Catch those and handle them decently

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

11.3 Define pay equity and explain its importance today.

Answered: 1 week ago