Using an example from your work or daily life describe an is
Using an example from your work or daily life, describe an \"is-a\" relationship. Why is an \"is-a\" relationship important when designing an inheritance between classes? What are the differences between \"is-a\" and \"has-a\" relationship?
Solution
is - a relationship
Example: consider a Professor,who can be guest faculty or full time faculty.
Professor is a
1. Guest faculty or
2. Full time Faculty.
When designing inheritance between classes is-a relationship is important because we need to analyse the common properites of sub classes and to implement them in super class to avoid complexity of implementing the features in all base classes. The base class features can be reused by all children classes.
Has -a relationship is an aggregation, where without super class there is no need of sub classes.
Example: Hospital has various specializations departments. without hospital there are no specialization departments.
Hospital can be implemented as a class and branches(classes) can be nested within hospital class.
Is-a relation is a classification; Has -a relation is an aggregation.
