-
It is desired to design an object-oriented employee record system for a company. Each employee has a name, unique Id and salary. Employees belong to different categories and their salary is determined by their category. The functions get Name, geld and compute salary are required. Given the class hierarchy below, possible locations for these functions are
1. getId is implemented in the superclass
2. getId is implemented in the subclass
3. getName is an abstract function in the superclass
4. getName is implemented in the superclass
5. getName is implemented in the subclass
6. getSalary is an abstract function in the superclass
7. getSalary is implemented in the superclas
8. getSalary is implemented in the subclass
Choose the best design.
-
- 1, 4, 6, 7
- 1, 4, 7
- 1, 3, 5, 6, 8
- 2, 5, 8
- 1, 4, 6, 7
Correct Option: A
ID is unique so can be implemented in the superclass.
Name is a function of superclass.
Also, Name can be common/duplicate, so must be implemented in superclass.
Salary is a function of superclass. Also, salary is dependent on the category and hence is implemented in the subclass.