Thursday 22 March 2012

Inheritance

Inheritance:

Inheritance is the process by which objects of one class acquire the properties of objects of another class. Inheritance supports the concept of hierarchical classification. For example, the bird robin is a part of the class flying bird, which is again a part of the class bird. As illustrated in Fig. 1.4, the principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived.


Property Inheritance 

 In 00P, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. This is possible by deriving a new class from the existing one. The new class will have the combined features of both the classes. Thus the real appeal and power of the inheritance mechanism is that it allows the Programmer to reuse a class that is almost, but not exactly, what he wants, and to tailor the class in such a way that it does not in introduce any undesirable side effects into the rest of the classes.In Java, the derived class is known as 'subclass'. Note that each subclass defines only those features that are unique to it. without the use of inheritance. each class Would have to explicitly include all of its features.

No comments:

Post a Comment