Which of the following is the main advantage of inheritance ?
Inheritance reduces the code duplication and improves the code maintainability.
Inheritance used for achieving abstraction.
Inheritance is used for reducing code redundancy or duplication , and hence improves code maintainability .
Assume you have class "A" with 5 methods and another class "B" with 8 methods , out of which 4 methods code is almost same as the methods present in class A. Later if you want to modify logic in these 4 common methods , you must change code in 8 methods which reduces the maintainability.
Back To Top