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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started