Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Do I really have to IMPLEMENT all methods from the parent class?
The question in the quiz says: "When you use the inheritance model of code re-use, you must implement ALL public methods provided by the parent class."
I stated this as false since I don't have to implement them all again. If I want to change them I have to override them, but if they are valid in the current implementation for my child class I can not mention them at all in my class or can't I?
I don't get why this is true...
Theodore Ravindranath41 Points
@mathiswiehl Agree with you completely. If it is an interface, you have to implement everything. But, in the case of inheritance in terms of extending a class, you would have to only override the methods whose functionality you want to change.
The question is wrong. The question should have been "When you use the inheritance model of code re-use, you must test ALL public methods provided by the parent class." and then the answer would have been "true". The disadvantage of inheritance, from the perspective of unit testing, is that you end up having to test all the methods, even ones that you did not author/modify.