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 =

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

1 Expert Approved Answer
Step: 1 Unlock

Program Plan Create a class called Course The class implements the Clonable interface to ... View full answer

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 Java Programming Questions!