11. |
What are the methods which begin and end with two underscore characters called?
|
||||||||
Answer:
Option (a) |
12. |
Special methods need to be explicitly called during object creation.
|
||||
Answer:
Option (b) |
13. |
What is hasattr(obj,name) used for?
|
||||||||
Answer:
Option (c) |
14. |
What is delattr(obj,name) used for?
|
||||||||
Answer:
Option (b) |
15. |
__del__ method is used to destroy instances of a class.
|
||||
Answer:
Option (a) |
16. |
What does print(Test.__name__) display (assuming Test is the name of the class)?
|
||||||||
Answer:
Option (c) |
17. |
Which of the following best describes inheritance?
|
||||||||
Answer:
Option (a) |
18. |
Which of the following statements is wrong about inheritance?
|
||||||||
Answer:
Option (c) |
19. |
What will be the output of the following Python code?
class Demo: def __new__(self): self.__init__(self) print(""Demo's __new__() invoked"") def __init__(self): print(""Demo's __init__() invoked"") class Derived_Demo(Demo): def __new__(self): print(""Derived_Demo's __new__() invoked"") def __init__(self): print(""Derived_Demo's __init__() invoked"") def main(): obj1 = Derived_Demo() obj2 = Demo() main()
|
||||||||
Answer:
Option (b) |
20. |
All subclasses are a subtype in object-oriented programming.
|
||||
Answer:
Option (b) |