Final answer:
To design the classes as described, you will start by creating a class called Employee. This class will have instance variables for name and salary with appropriate types and access modifiers. The class will also have a constructor that takes the values for name and salary. The name variable doesn't need to be changeable, but the salary should have a setter method to allow for changes.
Step-by-step explanation:
To design the classes as described, you will start by creating a class called Employee. This class will have instance variables for name and salary with appropriate types and access modifiers. The class will also have a constructor that takes the values for name and salary. The name variable doesn't need to be changeable, but the salary should have a setter method to allow for changes. Finally, override the toString method to print the employee details.
To create the Manager subclass, inherit from the Employee class. Add an additional instance variable called department with the appropriate access modifier. Use getters and setters to allow for changes to the department variable. The Manager class should have the same constructor as the Employee class. Override the toString method to include the department in addition to the employee details.
To create the Executive subclass, inherit from the Manager class. Add a new instance variable called numberOfShares to track the amount of shares the executive owns in the company's stock. Again, use getters and setters to allow for changes to this variable.