Extend a Method (Exercise)
00:00
Your second review exercise asks you to extend a method from the parent class. Give the sound argument of GoldenRetriever.speak() a default value of "Bark", the string "Bark". And again, you’re going to use the same Dog class as your parent class.
00:17
What you’re going to need to do here is to work with method overriding or extending. So you want to do something with the .speak() method from the Dog parent class, and you can see that it takes a sound as an argument, and you want to provide a default argument for GoldenRetriever.
00:34
So the child class called GoldenRetriever should have a default argument that the parent Dog class doesn’t have, so that if you don’t pass anything to .speak() on a GoldenRetriever object, then it should always say "Bark". Okay, that’s the task.
00:52 Try it out, and then move on to the next lesson, where we’ll code up a solution together.
Become a Member to join the conversation.
