5/2/26, 5:00 PM Java Inheritance Assignment
📚 INHERITANCE ASSIGNMENT
University Management System
Due Date: _______________ | Total Points: 100 | Individual Assignment
🎯 LEARNING OBJECTIVES
After completing this assignment, you will be able to:
Create parent-child class relationships using extends
Use super() for constructor chaining
Inherit fields and methods from parent classes
Add new fields and methods to child classes
Understand the constructor execution order
Use protected access modifier correctly
📊 CLASS HIERARCHY
Person (Given)
/ \
Student Teacher
/ \ \
GradStudent UnderGrad Professor
📝 GIVEN CODE (DO NOT MODIFY)
// File: [Link]
public class Person {
protected String name;
protected int age;
protected String id;
[Link]:5500/[Link] 1/7
5/2/26, 5:00 PM Java Inheritance Assignment
public Person(String name, int age, String id) {
[Link](">> Person constructor called");
[Link] = name;
[Link] = age;
[Link] = id;
}
public void eat() {
[Link](name + " is eating");
}
public void sleep() {
[Link](name + " is sleeping");
}
public void displayInfo() {
[Link]("ID: " + id + ", Name: " + name + ", A
}
public String getName() { return name; }
public String getId() { return id; }
public int getAge() { return age; }
}
✅ TASKS
Task 1: Create Student Class (20 points)
Create [Link] that extends Person with:
Fields (protected):
major (String)
year (int) - 1, 2, 3, or 4
Constructor:
Takes 5 parameters: name, age, id, major, year
Must call parent constructor
[Link]:5500/[Link] 2/7
5/2/26, 5:00 PM Java Inheritance Assignment
Print: ">> Student constructor called"
Methods:
study() - prints: "[name] is studying [major]"
attendClass() - prints: "[name] is attending [major] class"
displayStudentInfo() - calls parent's displayInfo() and prints major +
year
Task 2: Create GradStudent Class (20 points)
Create [Link] that extends Student with:
Fields (protected):
researchTopic (String)
supervisor (String)
Constructor:
Takes 7 parameters: name, age, id, major, year, researchTopic, supervisor
Must call parent constructor
Print: ">> GradStudent constructor called"
Methods:
doResearch() - prints: "[name] is researching: [researchTopic]"
writeThesis() - prints: "[name] is writing thesis under
[supervisor]"
displayGradInfo() - calls displayStudentInfo() and prints research
topic + supervisor
Task 3: Create UnderGrad Class (20 points)
Create [Link] that extends Student with:
Fields (protected):
hasInternship (boolean)
creditsCompleted (int)
Constructor:
Takes 7 parameters: name, age, id, major, year, hasInternship, creditsCompleted
Must call parent constructor
[Link]:5500/[Link] 3/7
5/2/26, 5:00 PM Java Inheritance Assignment
Print: ">> UnderGrad constructor called"
Methods:
takeExam() - prints: "[name] is taking final exam"
applyForInternship() - prints:
If true: "[name] already has an internship!"
If false: "[name] is applying for internship"
displayUnderGradInfo() - calls displayStudentInfo() and prints
internship status + credits
Task 4: Create Teacher Class (15 points)
Create [Link] that extends Person with:
Fields (protected):
department (String)
salary (double)
Constructor:
Takes 5 parameters: name, age, id, department, salary
Must call parent constructor
Print: ">> Teacher constructor called"
Methods:
teach() - prints: "[name] is teaching [department]"
gradePapers() - prints: "[name] is grading papers"
displayTeacherInfo() - calls parent's displayInfo() and prints
department + salary
Task 5: Create Professor Class (15 points)
Create [Link] that extends Teacher with:
Fields (protected):
specialization (String)
publications (int)
Constructor:
[Link]:5500/[Link] 4/7
5/2/26, 5:00 PM Java Inheritance Assignment
Takes 7 parameters: name, age, id, department, salary, specialization, publications
Must call parent constructor
Print: ">> Professor constructor called"
Methods:
publishPaper() - increments publications by 1 and prints:
"[name] published a paper! Total: [publications]"
conductResearch() - prints: "[name] is conducting research in
[specialization]"
displayProfessorInfo() - calls displayTeacherInfo() and prints
specialization + publications
Task 6: Create Main Class (10 points)
Create [Link] with main() method that:
1. Creates one object of EACH class: Person, Student, GradStudent, UnderGrad,
Teacher, Professor
2. For each object, call AT LEAST 3 methods (some inherited, some own)
3. Demonstrate constructor chaining by showing the order of constructor calls
4. Print a summary showing what each object can access from parent classes
📤 SUBMISSION REQUIREMENTS
Submit the following files:
1. [Link]
2. [Link]
3. [Link]
4. [Link]
5. [Link]
6. [Link]
Do NOT submit [Link] (it is given)
📊 RUBRIC (100 Points Total)
[Link]:5500/[Link] 5/7
5/2/26, 5:00 PM Java Inheritance Assignment
Criteria Points
Task 1: Student Class 20
Task 2: GradStudent Class 20
Task 3: UnderGrad Class 20
Task 4: Teacher Class 15
Task 5: Professor Class 15
Task 6: Main Class 10
⭐ BONUS CHALLENGE (+5 Extra Credit)
Create a new class PostDoc that extends GradStudent with:
Fields:
contractDuration (int months)
stipendBonus (double)
Methods:
conductSeminar() - prints seminar details
applyForGrant() - prints grant application
✅ VERIFICATION CHECKLIST
□ Every class has correct extends keyword
□ Every constructor calls super() with correct parameters
□ Every class has constructor print statement
□ All fields are protected
□ All methods have correct return types and parameters
□ Main class creates all 6 objects
□ Code compiles without errors
[Link]:5500/[Link] 6/7
5/2/26, 5:00 PM Java Inheritance Assignment
□ Output matches expected format
⚠️ COMMON MISTAKES TO AVOID
❌ Forgetting super() as first line in constructor
❌ Using private instead of protected for fields
❌ Not calling parent's display method in child's display method
❌ Trying to access private fields from child class
❌ Wrong constructor parameter order
📝 QUESTIONS TO ANSWER
Answer these in comments at the top of your [Link] :
1. What is the purpose of the super() keyword? Why must it be the first line?
2. What happens if you remove super() from a child constructor?
3. Can a GradStudent directly access Person's private fields? Why or why not?
4. Why do we use protected instead of private for fields in parent classes?
5. What is constructor chaining? Show the chain for Professor class.
🚀 GOOD LUCK! 🚀
Remember: Focus on INHERITANCE only - no method overriding needed yet!
[Link]:5500/[Link] 7/7