Question: Please dont post the answer as a pdf file, thank you! Programming Exercise 13.13 Rewrite the Course class in Listing 10.6 to add a clone

Please dont post the answer as a pdf file, thank you!
 Please dont post the answer as a pdf file, thank you!
Programming Exercise 13.13 Rewrite the Course class in Listing 10.6 to add

Programming Exercise 13.13 Rewrite the Course class in Listing 10.6 to add a clone method to perform a deep copy on the students field. Listing 10.6-Course.java public class Course private String courselane private Stringt) students- new Stringt11001 private int numberofstudents publie Course (String courselane) this.courseName courseNanez public void addstudent (String student) students [numberofstudents]- student numberofstudents++ publie StringI1 getstudents O return studentS publie at getNunberorstudentso return numberofstudentsi publie String getcourselane O return courselase publie void dropstudent (String student) Left as an exereise in Exereise 99 The implementation listed above will crash i more than 100 students are added. The addStudent method should be rewriten as follows public void addStudent (String student) f (nunStudents100) students [numberotstudentsl-student numberofstudents++ else System.out-printin("Course is full Returning a reference to the students array is a serious security issue since the client class is able to make modifications. The getStadent method should be rewritten as follows publie String getstudents O Stringt1 studentsCopy-new String Inumberofstudents) System.arraycopy (students, studentsCopy, 0, numberofStudents) return studentsCopy

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!