Sail E0 Webinar
Question
What is the output of the following piece of code?class A():    def disp(self):        print("A disp()")class B(A):    passobj = B()obj.disp()
Options:
A .  Invalid syntax for inheritance
B .  Error because when object is created, argument must be passed
C .  Nothing is printed
D .  A disp()
Answer: Option D


Class B inherits class A hence the function disp () becomes part of class B's definition. Hence disp() method is properly executed and the line is printed.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers