Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 12 - Inheritance and Polymorphism - Section 12.6 - The isinstance Function - Check Point - MyProgrammingLab - Page 413: 12.16

Answer

(a) Yes, goldenDelicious is an instance of Fruit. (b) No, goldenDelicious is not an instance of Orange. (c) Yes, goldenDelicious is an instance of Apple. (d) Yes, goldenDelicious is an instance of GoldenDelicious. (e) No, goldenDelicious is not an instance of McIntosh. (f) Yes, orange is an instance of Orange. (g) Yes, orange is an instance of Fruit.

Work Step by Step

If a class A inherits from class B and class B inherits from class C, and you create an instance of class A, then that object will also be an instance of class B and class C. This is because inheritance in Python works in such a way that an object of a derived class has all the properties and behaviors of the base class(es). So in this case, the object of class A will have all the properties and behaviors of both class B and class C. And if a class X is not an ancestor of the class A of the current object, then class X does not inherits object of class A.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.