Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Enable the Course class cloneable. Rewrite the Course class to add a clone method to perform a deep copy on the students field. Write a

Enable the Course class cloneable. Rewrite the Course class to add a clone method to perform a deep copy on the students field. Write a test program that creates a course, populates it with 5 students (with the following names: Eddie Woodward, Tiana Hopkins, Ariel Ortiz, Tanner Rubio, and Aubree Mccall), clones the object, and prints whether the two students fields point to the same array (i.e., it should print false) .

public class Course {

private String courseName;

private String[] students = new String[4];

private int numberOfStudents;

public Course(String courseName) {

this.courseName = courseName;

}

public void addStudent(String student) {

students[numberOfStudents] = student;

numberOfStudents++;

}

public String[] getStudents() {

return students;

}

public int getNumberOfStudents() {

return numberOfStudents;

}

public String getCourseName() {

return courseName;

}

public void dropStudent(String student) {

// Left as an exercise in Exercise 10.9

}

}

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

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

The Nature of Nonverbal Communication

Answered: 1 week ago

Question

Functions of Nonverbal Communication

Answered: 1 week ago

Question

Nonverbal Communication Codes

Answered: 1 week ago