Chapter 12: Problem 3
What does a subclass inherit from its superclass?
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 12: Problem 3
What does a subclass inherit from its superclass?
All the tools & learning materials you need for study success - in one app.
Get started for free
Look at the following class definitions: class Vegetable: def _ _init_ _(self, vegtype): self._ _vegtype = vegtype def message(self): print("I'm a vegetable.") class Potato(Vegetable): def _ _init_ _(self): Vegetable._ _init_ _(self, 'potato') def message(self): print("I'm a potato.") Given these class definitions, what will the following statements display? v = Vegetable('veggie') p = Potato() v.message() p.message()
What does it mean to say there is an 鈥渋s a鈥 relationship between two objects?
Look at the following code, which is the first line of a class definition. What is the name of the superclass? What is the name of the subclass? class Canary(Bird):
What do you think about this solution?
We value your feedback to improve our textbook solutions.