answersLogoWhite

0


Best Answer

One of the earliest motivations for using inheritance was the re-use of code which already existed in another class. This practice is usually called implementation inheritance.

In most quarters, class inheritance for the sole purpose of code re-use has fallen out of favor.The primary concern is that implementation inheritance does not provide any assurance of polymorphic substitutability-an instance of the re-using class cannot necessarily be substituted for an instance of the inherited class. An alternative technique, delegation, requires more programming effort but avoids the substitutability issue. In C++ private inheritance can be used as form of implementation inheritance without substitutability. Whereas public inheritance represents an "is-a" relationship and delegation represents a "has-a" relationship, private (and protected) inheritance can be thought of as an "is implemented in terms of" relationship.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How does inheritance promote code reuse?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why you need to use inheritance?

Inheritance is an object oriented programming concept that helps us with the following benefits:You can reuse existing code instead of having to write them againredundancy of code is avoidedrework and maintenance is easy


What could be the main advantage of inheritance concept of object orientation?

Code Reuse and avoiding redundancy is the main advantage of inheritance concept. Using inheritance, instead of rewriting a piece of code again in a class, we inherit the features from the parent class and use it instead


Can you reuse your mopod code on moshi mosnters?

No, You can't reuse your code.


Which concept in java implements the concept of reusabilityand what are it's types?

One important aspect of code reuse is related to inheritance, which is a standard part of OOP programming.


The ways in which inheritance promotes software reuse?

Inheritance allows classes to be reused by creating a direct relationship superclasses and subclasses. By allowing a subclass to inherit from a superclass, less code is required to develop new subclasses. Hence how the term reuse comes into play. A subclass is essentially "reusing" what has already been developed in the superclass.


What is public inheritance in java?

Inheritance is a Java feature by which we can reuse code and programming logic from one class in another class. We implement Inheritance using the extends keyword.Ex: public class Ferrari extends Car {…}Here the Ferrari Class will extend features from the Car Class.This is Inheritance. The different types of Inheritance are:Single InheritanceMulti-Level InheritanceMultiple Inheritance (Java supports only Partial Multiple Inheritance) andHybrid Inheritance


What is hierarchal inheritance?

Hierarchical inheritance is a type of inheritance in object-oriented programming where classes are organized in a hierarchical structure. It means that a derived class can inherit attributes and methods from a base or parent class, and it can further be inherited by other classes. This allows for code reuse and promotes modularity in the program.


What is a use inheritance?

Code Re-use is one of the biggest uses of Inheritance


How do you reuse an iTunes code?

you dont. there for single use


Which is the mechanism of reusing the existing class without modification?

we can use classes in java...by inheritance concept...we can reuse without modification


Can you reuse code on moshi monsters?

It depends where the code came from. There are many moped codes that are availabe which you can reuse. However, codes which came from cards/stickers can not be used twice.


What is the use of reusability in inheritance?

Inheritance in Java refers to the feature wherein the code/functionality of one class can be used in another class that extends this class. Example: public class Parent { ... .. } public class Child extends Parent { ... .. . } Here the class Child extends the class Parent and hence the methods of Parent are available for Child to use. This way we are re-using the code in the parent class in the child class instead of re-writing the whole thing again.