Question: In Java, Student class (10) Has three instance variables: name and dept are of type String id is an int Default constructor uses mutators to

In Java,

Student class (10)

Has three instance variables:

name and dept are of type String

id is an int

Default constructor uses mutators to set name and dept to and id to 0.

The other constructor has three parameters for Siring name, int id, and String dept and uses the mutators to set the instance variables for these values.

There are three mutators and three accessors methods for the three instance variables.

There is a toString() method which returns the name, id and dept as a String on a single line

Department class (10)

Has two instance variables.

deptName a String variable

studentList an ArrayList of type Student

Default constructor uses the mutator to set deptName to

The other constructor has a String parameter for the deptName and uses a mutator to set the instance variable for this value.

method addStudent has a reference to a Student as a parameter and a void return.

It adds the reference to the Student to the studentList

method getStudentList has a no parameters and a reference to an ArrayList of type Student as a return value.

It returns a reference to the ArrayList studentList for this department

There is a mutator and accessor method for deptName.

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!