One of the features of object-oriented programming is inheritance. As the name suggests, a class gains some abilities from an existing class. In more definite terms, it is a form of software reuse in which a new class is created by an existing class members and instilling them with new or changed capabilities. With inheritance existing programs can be easily modified to accommodate a new feature without the use of overhaul or rewriting. It also helps during program development by reusing tried and tested software. Inheritance works by designating a new class should inherit the members of an existing class. The existing class is called superclass in Java or base class in C++ and the new class as the subclass or derived class.

Each subclass can become the superclass for future subclasses. A subclass normally adds its own fields and methods. Therefore, a subclass is more specific than its superclass and represents a more specialized group of objects. Typically, the subclass exhibits the actions of its superclass and additional characteristics that are specific to the subclass. The direct superclass is the superclass from which it inherits. It may have one or more indirect superclass which refers to the superclasses in the hierarchy. If a subclass inherits from only one only superclass, it is called single inheritance. From experiences in software development, it is most often that large amounts of code deal with similar special cases. These special cases preoccupy the programmers, making the details for the system as a whole not granted sufficient attention. With object-oriented programming, one focuses on the special cases. This type of programming effect widely thrust the need to relate existing classes to new classes. In other words, it is an is-a relationship is one where an object of a subclass can also be treated as an object of its superclass.

Posted 2011-01-29 and updated on Jun 08, 2011 2:30am by crisd

 Jun 08, 2011 2:30amStands back from the kyebaord in amazement! Thanks! by Monkey
You may write your reply now.
Name : ZIP(optional) :
Please DO NOT use html tags or links.


Since 2010 by Noel Allosa