answersLogoWhite

0

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

15y ago

What else can I help you with?

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 object composition and delegation?

Object composition is a design technique where an object contains other objects as attributes to achieve reuse and modularity. Delegation is a programming pattern where an object passes responsibilities to another object to achieve code reuse and maintainability. Both techniques promote code reuse, modularity, and maintainability in object-oriented programming.


How inheritance specified in generalization?

Inheritance in generalization is a concept from object-oriented programming and design, where a subclass inherits properties and behaviors (methods) from a parent class (superclass). This allows the subclass to reuse code, promote modularity, and establish a hierarchical relationship between classes. Generalization abstracts common characteristics into a base class, enabling more specific subclasses to extend or override features as needed. This facilitates code maintenance and enhances the ability to model real-world relationships.


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 are the advantages of using Hierarchical Inheritance in Java?

Hierarchical inheritance in Java allows multiple subclasses to inherit from a single parent class, promoting code reuse and reducing redundancy. Key advantages include: Code Reusability: Subclasses inherit common properties and methods from the parent class, reducing the need to write repetitive code. Maintainability: Changes made to the parent class are automatically reflected in all subclasses, simplifying code maintenance. Modularity: It enables a clear structure where common functionality is centralized, and specific features can be extended in subclasses. Efficiency: Inheritance minimizes code duplication, leading to more efficient and streamlined code.


What is direct and indirect inheritance?

Direct inheritance refers to a situation where a class (subclass) inherits properties and methods directly from another class (superclass) without any intermediary classes. In contrast, indirect inheritance occurs when a subclass inherits from a superclass that itself inherits from another class, creating a chain of inheritance. This allows subclasses to access attributes and methods from multiple layers of superclasses, promoting code reuse and a more organized class structure.


How can we incorporate the principles of reduce, reuse, and recycle into our daily lives to promote sustainability?

To promote sustainability, we can incorporate the principles of reduce, reuse, and recycle into our daily lives by minimizing waste through using less, finding ways to reuse items, and properly recycling materials to conserve resources and protect the environment.