This Python Constructor Quiz helps you master the role of __init__() in class-based programming. Learn how constructors work, how to customize them, and how Python uses them behind the scenes when creating objects.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
class A: def __init__(self): print(“Init called”) a = A()
Correct
Incorrect
Question 4 of 15
4. Question
What is the purpose of self in __init__()?
Correct
Incorrect
Question 5 of 15
5. Question
Can __init__() accept arguments?
Correct
Incorrect
Question 6 of 15
6. Question
What is the output of this code?
class Book: def __init__(self, title): self.title = title b = Book(“Python”) print(b.title)
Correct
Incorrect
Question 7 of 15
7. Question
How many constructors can a Python class have?
Correct
Incorrect
Question 8 of 15
8. Question
What happens if a class does not define an __init__() method?
Correct
Incorrect
Question 9 of 15
9. Question
Which statement is true about __init__()?
Correct
Incorrect
Question 10 of 15
10. Question
What does this code return?
Correct
Incorrect
Question 11 of 15
11. Question
Can __init__() be overloaded like in Java or C++?
Correct
Incorrect
Question 12 of 15
12. Question
What will type(b) return in the following code?
class B: def __init__(self): self.val = 10 b = B() print(type(b))
Correct
Incorrect
Question 13 of 15
13. Question
Which line correctly defines a constructor with parameters?
Correct
Incorrect
Question 14 of 15
14. Question
What happens when you call a class like User()?
Correct
Incorrect
Question 15 of 15
15. Question
What will happen if you try to return a value from __init__()?
Correct
Incorrect
Summary
These Python Constructor multiple-choice questions solidify your understanding of how __init__() works, how it initializes objects, and how parameters can be used during object creation. A strong grasp of constructors is essential for writing reusable OOP code in Python.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.