Consider the following outline of a class Student: public class Student { private String name; private String ident; public Student() { ... } public Student(String studentName, String studentId) { ......


Consider the following outline of a class Student:


public class Student


{


private String name;


private String ident;


public Student() { ... }


public Student(String studentName, String studentId) { ... }


public void setStudent(String studentName, String studentId) { ... }


public String getName() { ... }


public String getId() { ... }


public String toString() { ... }


} // end Student


Now consider the following outline of a class CollegeStudent:


public class CollegeStudent extends Student


{


private int year;


private String degree;


public CollegeStudent() { ... }


public CollegeStudent(String studentName, String studentId,


int graduationYear, String degreeSought) { ... }


public void setStudent(String studentName, String studentId,


int graduationYear, String degreeSought) { ... }


public String getYear() { ... }


public String getDegree() { ... }


public String toString() { ... }


} // end CollegeStudent


a. Does the method setStudent in CollegeStudent overload or override the method setStudent in the class Student? Explain.


b. The class CollegeStudent does not define methods that get the student’s name and identification number. Why?


c. Define the constructors for CollegeStudent. Can you omit a call to super in the default constructor? Can you omit it in the second constructor? Give reasons for your answers.


d. Define the method setStudent for CollegeStudent.


e. Can the method setStudent for CollegeStudent contain the following statement?


name = studentName;


Explain.


f. If joe is an object of the class CollegeStudent, write Java statements that display joe’s name.


g. If the method toString in Student returns a string containing the student’s name and identification number, and toString in CollegeStudent returns a string containing the student’s name, identification number, year, and degree, can CollegeStudent’s toString call Student’s toString? If so, what statement will make this call? If not, why not?

May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here