In: Computer Science
How is inheritance is a one-way association between classes. What does this mean? Also need examples.
association defines a relationship between classes of objects that allows one object instance to cause another to perform an action on its behalf
inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining similar implementation. Also defined as deriving new classes (sub classes) from existing ones such as super class or base class and then forming them into a hierarchy of classes
One subclass can extend only one super class and only be inherited in same package subclass, not in another package that's why inheritance is called as one way association .
Example:-
Currency is called parent class while Rupee is a child of Currency class. In object oriented programming term, Currency is super class while Rupee is a subclass. It means Rupee inherits all non-private members e.g. fields and methods but cannot inherit in other super class
Hope you like my answer ,please give good ratings thank you