// Package declaration: This class is part of the 'oop' package
package oop;
// 'Engineer' class extends the 'Person' class, meaning it inherits all fields and
methods from 'Person'
public class Engineer extends Person {
// Instance variable specific to Engineer
double salary; // Engineer's salary
// Constructor for the Engineer class
// Calls the constructor of the superclass (Person) using 'super' and sets the
salary
public Engineer(String name, String address, String major, int age, String
gender, double salary) {
super(name, address, major, age, gender); // Call to the parent class
(Person) constructor
[Link] = salary; // Set the salary field for the
Engineer
}
// Override the printInfo method to add salary to the printed information
@Override
public void printInfo() {
[Link](); // Call the superclass version
of printInfo to print basic info
[Link]("Salary: " + salary); // Print the Engineer's salary
}
}