Python Programming - Inheritance - Discussion
Discussion Forum : Inheritance - General Questions (Q.No. 97)
97.
Consider the following code:
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
class EBook(Book):
def __init__(self, title, author, format_type):
super().__init__(title, author)
self.format_type = format_type
What is the primary advantage of using super().__init__(title, author)
in the EBook
class constructor?
Answer: Option
Explanation:
super().__init__(title, author)
is used to call the constructor of the superclass Book
and initialize the title
and author
attributes.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers