Question

In: Computer Science

How is inheritance is a one-way association between classes. What does this mean? Also need examples.

How is inheritance is a one-way association between classes. What does this mean? Also need examples.

Solutions

Expert Solution

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


Related Solutions

what is the association between smoking and coffee and also an association between smoking and myocardial...
what is the association between smoking and coffee and also an association between smoking and myocardial infarction.
What is the difference between “vertical inheritance” and “horizontal inheritance”? Does horizontal inheritance of genes provide...
What is the difference between “vertical inheritance” and “horizontal inheritance”? Does horizontal inheritance of genes provide evidence against Darwin’s theory of Evolution by Natural Selection? Why or why not?
What does it mean to say that schizoprehenia is multifactorialin inheritance?
What does it mean to say that schizoprehenia is multifactorial in inheritance?
Explain the difference between Limited and Reasonable Assurance, also give one example of each. Need Examples...
Explain the difference between Limited and Reasonable Assurance, also give one example of each. Need Examples and evaluated answer.
Database Design In the EER modeling process, what does inheritance mean? Give one specific example of...
Database Design In the EER modeling process, what does inheritance mean? Give one specific example of it.
What does it mean to make user classes in SQL?
What does it mean to make user classes in SQL?
The relationship between Laptop and Screen can best be categorized as Inheritance Association Ownership Private What...
The relationship between Laptop and Screen can best be categorized as Inheritance Association Ownership Private What is the purpose of information hiding in object-oriented programming? To protect the values of variables from being changed inappropriately To free other programmers from having to know too many details of the inner workings of the class. To protect people’s personal information from hackers? All of the above Just choices a and b The relationship between Bayonet and Weapon could best be described as...
When exploring the strength of the association between variables, which is the appropriate test? a. One-way...
When exploring the strength of the association between variables, which is the appropriate test? a. One-way ANOVA b. Paired sample t test c. Correlation or regression d. Factorial ANOVA
In human genetics, what is the difference between autosomal and sex-link traits? How does the inheritance...
In human genetics, what is the difference between autosomal and sex-link traits? How does the inheritance pattern for autosomal traits differ from the inheritance of sex-linked traits ?
I need to see a working example using inheritance and the classes (below) The person class...
I need to see a working example using inheritance and the classes (below) The person class has first name last name age hometown a method called getInfo() that returns all attributes from person as a String The student class is a person with an id and a major and a GPA student has to call super passing the parameters for the super class constructor a method called getInfo() that returns all attributes from student as a String this methods has...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT