Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programing Language Please write your code in JAVA a. Create a class called Battery containing a battery number (as a unique identifier) of type

Java Programing Language
Please write your code in JAVA
image text in transcribed
a. Create a class called Battery containing a battery number (as a unique identifier) of type int, a manufacturer of type String, and expiration date of type Date. Make it cloneable and implement its toString() method. b. Create a class called Toy that contains a name of type String, and an array of Battery and a toString() method that prints out info about all its batteries. Write a clone() for Toy that automatically clones its name and all of its Battery objects. c. Make sure that the clone() methods catch the CloneNotSupportedException rather than passing it to the caller, as shown in the Textbook. d. Write test methods only for the clone() methods that will do the cloning and print out the input parameter(s), expected results, and actual results. Choose 2-3 appropriate inputs to validate that they perform deep cloning (and not do shallow cloning.)

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_2

Step: 3

blur-text-image_3

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

How did you select your consultant to help choose your ERP vendor?

Answered: 1 week ago