Question: Rewrite the Course class in Listing 10.6 to add a clone method to perform a deep copy on the students field. Listing 1 public class
Rewrite the Course class in Listing 10.6 to add a clone method to perform a deep copy on the students field.
Listing
![1 public class Course { private String courseName; private String[] students =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/11/636a7314d2bff_660636a7314c2bc0.jpg)
1 public class Course { private String courseName; private String[] students = new String[100]; private int numberofStudents; 2 3 5 public Course(String courseName) { this.courseName = courseName; public void addStudent (String student) { students[number0fStudents] = student; numberofStudents++; 10 11 12 13 14 public String[] getStudents() { return students; 15 16 17 18 19 20 21 22 23 24 public int getNumber0fStudents() { return number0fStudents; public String getCourseName () { return courseName; 25 26 27 public void dropStudent(String student) { // Left as an exercise in Programming Exercise 10.9 } 28 29 30 } wN2 NNN NNNN
Step by Step Solution
3.54 Rating (168 Votes )
There are 3 Steps involved in it
Program Plan Create a class called Course The class implements the Clonable interface to ... View full answer
Get step-by-step solutions from verified subject matter experts
