Question: In this next example, we'll build two classes that implement the Cloneable Interface. The QuizTracker class contains an ArrayList of QuizScore objects, and it's up

 In this next example, we'll build two classes that implement the

In this next example, we'll build two classes that implement the Cloneable Interface. The QuizTracker class contains an ArrayList of QuizScore objects, and it's up to us to build these two classes so that we can make deep copies of QuizTrackers (and share no internal aliases). The key idea here is that to make deep copies of compound objects (or lists of objects), we need to copy (using clone) every object in every list, and even make copies of the list objects (ArrayLists here) themselves. (1) Start by building a small QuizScore Class that contains only one data item: an int that corresponds to the score received on the quiz. (2) Build a second class, QuizTracker, that contains an ArrayList of QuizScore objects (Array List ) as its only data item a. This is just like an IntList covered previously, but instead of ints well be storing QuizScore and instead of arrays we can use an ArrayList here. (3) Add getters and setters to QuizScore for the score, and provide an add(QuizScore) method for class QuizTracker (4)Implement the cloneable interface for the QuizScore class (5) Implement the cloneable interface for the QuizTracker class, as well a. This should not use ArrayList. Clone(), as this is a shallow copy. B. Instead, to create a copy of QuizTracker, you must first build a newly created ArrayList in (b) c. In this way, if we, make a copy of the container (ArrayList), and all the contents in the container (QuizScores), weve succeeded in producing a deep copy for the QuizTracker class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!