Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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.