Create Student class•Change header so that Student extends Person•A Student has-an additional instance variable, major of type String.•Add the instance variable, its getters and setters. •Add a toString method to the Student class. It should reuse the toString method of Person. •Add two constructors: –No args–Constructor that receives the student’s name, birth year and Major as parameters•Create a class TestInheritance3–Create 2 Student objects–Create an Instructor object–Print the information about the two students and the instructor using the getters of Person, Student and Instructor.
Person.java
public class Person {
private String name;
private int birthYear;
public Person()
{
name = "";
birthYear = 0;
}
public Person(String theName, int bYear)
{
name = theName;
birthYear = bYear;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getBYear() {
return birthYear;
}
public void setYear(int birthYear) {
this.birthYear = birthYear;
}
@Override
public String toString()
{
return "Name: " + name + " BYear: " + birthYear;
}
}
Student.java
public class Student extends Person{
private String major;
public Student()
{
super();
major = "";
}
public Student(String name, int birthYear, String major)
{
super(name, birthYear);
this.major = major;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
@Override
public String toString()
{
return (super.toString() + " Major: " + major);
}
}
Instructor.java
public class Instructor extends Person{
private String department;
public Instructor()
{
super();
department = "";
}
public Instructor(String name, int birthYear, String
department)
{
super(name, birthYear);
this.department = department;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
@Override
public String toString()
{
return (super.toString() + " Department: " + department);
}
}
TestInheritance3.java (Main class)
public class TestInheritance3 {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
// creating 2 student objects
System.out.print("Student 1 details:\n------------------\nEnter
name: ");
String sName1 = sc.nextLine().trim();
System.out.print("Enter birth year: ");
int sBYear1 = sc.nextInt();
sc.nextLine(); // to consueme the next line after taking an integer
input
System.out.print("Enter major: ");
String sMajor1 = sc.nextLine().trim();
Student s1 = new Student(sName1, sBYear1, sMajor1);
System.out.print("\nStudent 2 details:\n------------------\nEnter
name: ");
String sName2 = sc.nextLine().trim();
System.out.print("Enter birth year: ");
int sBYear2 = sc.nextInt();
sc.nextLine(); // to consueme the next line after taking an integer
input
System.out.print("Enter major: ");
String sMajor2 = sc.nextLine().trim();
Student s2 = new Student(sName2, sBYear2, sMajor2);
// creating an Instructor object
System.out.print("\nInstructor details:\n------------------\nEnter
name: ");
String instName = sc.nextLine().trim();
System.out.print("Enter birth year: ");
int instBYear = sc.nextInt();
sc.nextLine(); // to consueme the next line after taking an integer
input
System.out.print("Enter department: ");
String instDept = sc.nextLine().trim();
Instructor instructor = new Instructor(instName, instBYear,
instDept);
System.out.println("\n\nStudents present:\n-----------------\n1. "
+ s1.toString() + "\n2. " + s2.toString());
System.out.println("\n\nInstructor:\n-----------\n" +
instructor.toString());
if(instructor.getDepartment().equals(s1.getMajor()))
{
System.out.println("\n" + instructor.getName() + "(Instructor) is
of " + s1.getName() + "'s department.");
}
else if(instructor.getDepartment().equals(s2.getMajor()))
{
System.out.println("\n" + instructor.getName() + "(Instructor) is
of " + s2.getName() + "'s department.");
}
else
System.out.println("\nNo students of " + instructor.getDepartment()
+ " department are present!");
}
}
**************************************************************** SCREENSHOT ***********************************************************

Create Student class•Change header so that Student extends Person•A Student has-an additional instance variable, major of...
Implement a superclass Person. Make two classes, Student and Instructor, that inherit from Person. A person has a name and a year of birth. A student has a major, and an instructor has a salary. Writhe the class definitions, the constructors, and the methods toString for all classes. For Person the constructors should include a no-arg constructor and one that accepts in the name of the person. For student there should be a no-arg constructor and a constructor that accepts...
Need help to create general
class
Classes Data Element - Ticket Create an abstract class called Ticket with: two abstract methods called calculateTicketPrice which returns a double and getld0 which returns an int instance variables (one of them is an object of the enumerated type Format) which are common to all the subclasses of Ticket toString method, getters and setters and at least 2 constructors, one of the constructors must be the default (no-arg) constructor. . Data Element - subclasses...
Write a program that meets the following requirements: Sandwich Class Create a class called Sandwich which has the following instance variables. No other instance variables should be used: - ingredients (an array of up to 10 ingredients, such as ham, capicola, American cheese, lettuce, tomato) -condiments (an array of up to 5 condiments, such as mayonnaise, oil, vinegar and mustard) Create a two argument constructor Write the getters and setters for the instance variables Override the toString method using the...
Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...
Java help: 1.1) Create a class TA that extends class Student. 1.2) Add a variable to the TA class to represent the course the student is TA'ing. 1.3) Provide a constructor for the class so the code in the PeopleFactory will work as provided. 1.4) Provide a toString() method for the TA class so that TA's will output as shown in the sample code. Provide a class Staff so that you can un-comment the lines of code in the PeopleFactory class that...
Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...
Write an abstract class “Student” and three concrete classes, “UnderGrad” and “Graduate” both inherit from Student and “PostGraduate” that inherits form “Graduate”. Write the class definition for the abstract class “Student”. The class definition should include private instance variables of type String to hold the student’s first name, a string for his/her major and an int to hold the number of units taken. Getter and setter methods for each of the variables should be included in the class definition. Also...
Create a Business class: Instance variables: Student id 1000 - 9999 Student name Present Student email address Present Number of hours 3.5 - 18 Two constructors should be coded, one that accepts no arguments and sets every field to its default value, and one that accepts all four fields, and assigns the passed values into the instance variables. For each instance variable create two methods; a getter and a setter. Add a static method to the class that will accept...
1- Create the base class Book that has the following instance variables, constructor, and methods title ( String) isbn ( String) authors (String) publisher (String) edition ( int) published_year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method // that return sting representation of Book object. 2- Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title ( String) isbn...
java. Question 2: Practice Polymorphism- Food A Assume you have a parent class called Food with one instance data variable: private String name. The class has one constructor that takes the name as a parameter, getters and setters for name, and a toString that outputs the name. Write a child class called Vegetable with one additional variable describing whether or not the vegetable is green. Write two constructors: one that takes in all information about a vegetable and one that...