InterviewSolution
| 1. |
Explain The Isa And Hasa Class Relationships. How Would You Implement Each In A Class Design? |
|
Answer» A specialized CLASS "is" a specialization of another class and, therefore, has the ISA RELATIONSHIP with the other class. An EMPLOYEE ISA Person. This relationship is best implemented with inheritance. Employee is DERIVED from Person. A class may have an instance of another class. For example, an employee "has" a salary, therefore the Employee class has the HASA relationship with the Salary class. This relationship is best implemented by embedding an object of the Salary class in the Employee class. A specialized class "is" a specialization of another class and, therefore, has the ISA relationship with the other class. An Employee ISA Person. This relationship is best implemented with inheritance. Employee is derived from Person. A class may have an instance of another class. For example, an employee "has" a salary, therefore the Employee class has the HASA relationship with the Salary class. This relationship is best implemented by embedding an object of the Salary class in the Employee class. |
|