Discuss the ways in which inheritance promotes software reuse, saves time during program development and helps prevent errors.
What will be an ideal response?
Inheritance allows developers to create derived classes that reuse code declared already in a base class. Avoiding the duplication of common functionality between several classes by building an inheritance hierarchy to contain the classes can save developers a considerable amount of time. Placing common functionality in a single base class, rather than duplicating the code in multiple unrelated classes, helps prevent the same errors from appearing in multiple source-code files and makes debugging easier. If several classes each contain duplicate code containing an error, the software developer has to spend time correcting each source-code file with the error. However, if these classes take advantage of inheritance, and the error occurs in the common functionality of the base class, the software developer needs to modify only the base class’s code.
You might also like to view...
When the Sort Smallest to Largest option is selected from the Filter gallery, the Filter button displays ________
A) another up-arrow icon B) another down-arrow icon C) in red D) in green
What is it called when a hash function maps two or more search keys into the same integer
a. an accident b. a collision c. a perfect hash function d. an exception