Question: Complete the inheritance exercise ( Student, Person, and StudentDemo classes ) described below: Write a class named Person with String fields for holding a persons
Complete the inheritance exercise (Student, Person, and StudentDemo classes) described below: Write a class named Person with String fields for holding a persons name, address, and phone number. Write two constructors and the appropriate setter and getter methods for the three fields stated above. Write a class named Student which extends the Person class. The Student class should have a field for a student ID number such as 7723456 which is a String and a boolean field which indicates if the student wants to be on the schools email distribution list. Write two constructors and the appropriate setter and getter methods for the classs fields. Write a test class named StudentDemo which demonstrates one or two objects of the Student class. Helpful Hints: public class Student extends Person // Inherit from the Person class { private String studentNumber; // Student number private boolean mailingList; // Add to mailing list? (true or false) public Student( ) // Default constructor { super( ); // Invoke the Super class constructor studentNumber = ""; mailingList = false; } public Student(String n, String a, String p, String id, boolean m) // Invoke the Super class constructor again { super(n, a, p); studentNumber = id; mailingList = m; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
