Question: public class Teacher extends Person { //Data Members private String TeacherID; private String Course; private String Type; //Default Constructor public Teacher() { super(); this.TeacherID =

public class Teacher extends Person {

//Data Members

private String TeacherID;

private String Course;

private String Type;

//Default Constructor

public Teacher()

{

super();

this.TeacherID = "Unknown";

this.Course = "Unknown";

this.Type = "Casual";

}

//Non-default constructor

public Teacher(String FN, String LN, int Age, String GN, String City, String TID, String Course, String Type)

{

super(FN, LN, Age, GN, City);

this.TeacherID = TID;

this.Course = Course;

this.Type = Type;

}

//toString method

public String toString()

{

String Print;

Print = " Teacher Details:" + super.toString() + " Teacher ID: " + this.TeacherID + " Course: " + this.Course +

" Type: " + this.Type;

return Print;

}

}

Teacher Class

Consider Teacher class as a sub class of Person

  1. What is the additional attribute that a teacher class can have?
  2. Discuss the different types of constructor that this class can have and how will you use Super keyword?
  3. Override the toString() method of person class which will display the all details of that particular person.

Create a test class and test all classes by creating their objects and by calling their toString() method.

Create a rough class diagram for above scenario.

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!