HomeCode HerePython object-oriented quiz Python object-oriented quiz Admin 1 min read Updated November 16, 2026 Eight questions on classes, objects, init, self, methods and inheritance. Python Python object-oriented quiz 8 questions, instant feedback Question 1 of 8 Which keyword defines a class? A object B class C struct D new class Dog: starts a class definition. The body is indented like a function body. Question 2 of 8 When does __init__ run? A When the class is defined B When an object is created C When the object is printed D When the file is closed __init__ is the initializer: it runs once each time you create an instance. Question 3 of 8 What does self refer to inside a method? A The class itself B The current object C The module D The parent class self is the particular object the method was called on, which is how methods reach that object's attributes. Question 4 of 8 How do you make Dog inherit from Animal? A class Dog extends Animal: B class Dog(Animal): C class Dog inherits Animal: D class Dog -> Animal: The parent class goes in parentheses after the new class name. Java and C# use extends or a colon instead. Question 5 of 8 In a class, an attribute is… A Data stored on an object B A function in a module C A loop counter D A file handle Attributes hold an object's data, such as self.balance. Methods are the functions that work with it. Question 6 of 8 A method is… A A variable outside a class B A function defined inside a class C A built-in module D A type of loop Methods are functions attached to a class, which is why they can use self. Question 7 of 8 What does __str__ control? A How the object is sorted B The text shown by print(object) C The object's memory size D Whether the class can be inherited __str__ returns the human-readable text used by print() and str(). Question 8 of 8 Which line creates an object from a class called Task? A Task = new() B task = Task() C task = Task D task := Task Calling the class like a function creates an instance and runs __init__. Check my answers Try again Your answers stay in this browser. Nothing is sent to a server. More quizzes Python functions and modules quiz Coming soon Python final quiz Coming soon Python control flow quiz Coming soon All quizzes