Understand how to use inheritance in Java
Inheritance allows you to extend a class in Java.
This lab assignment will ask you to write a program using inheritance.
1. Create a New Project named InheritanceDemo .
2. Create a new class called Person and cut and paste the Person.java file from Blackboard into the class. Create a new class called Student and cut and paste the Student.java file from Blackboard into the class. Cut and paste the InheritanceDemo.java file from Blackboard into the InheritanceDemo class.
3. Create a new class called GraduateStudent that inherits from class Student. Add two instance variables, a String called major and a double called gpa. Add two constructors, one with no parameters and one with four. Make sure you call the super constructors for each of them. Write the accessor methods and the mutator methods for major and gpa. Write a reset() method that resets the name, studentNumber, major, and gpa. Finally, write a writeOutput() method that prints out all four values for the GraduateStudent class.
4. Uncomment the commented lines in InheritanceDemo.java. Compile the project and then execute it. What does it output?Attachments
private int studentNumber;
public Student ()
studentNumber = 0; //Indicating no number yet
public Student (String initialName, int initialStudentNumber)
studentNumber = initialStudentNumber;