<
RHD
/>
Home
Blog
Quiz
Resources
About
Contact
Enlist
// guest
▾
Login
Request Account
[ light ]
// Object-oriented programming
Object-oriented programming Quiz
// question 1 of 10
What is the correct way to avoid mutable default argument issues?
Define the argument as a class attribute
Use an empty tuple as default instead of a list
Use None as default and create the object inside __init__
// question 2 of 10
What does NotImplementedError signal in an abstract method?
That the method is deprecated
That the method has a bug
That the method must be overridden by a child class
// question 3 of 10
What is the correct syntax for a child class inheriting from Animal?
class Dog extends Animal
class Dog(Animal)
class Dog inherits Animal
// question 4 of 10
What is a property setter?
A method decorated with @attr.setter that validates before setting an attribute
A method that returns the value of a private attribute
A class attribute that cannot be changed
// question 5 of 10
What does the pass keyword do inside an empty class body?
Skips the class definition entirely
Acts as a placeholder that raises an error later
Allows the class to be defined without any content
// question 6 of 10
What is tight coupling in OOP?
When classes depend heavily on each other's internal details
When all methods are defined in one class
When a class inherits from multiple parents
// question 7 of 10
What does __str__ define?
The length of the object
The way two objects are compared
The string representation returned by print()
// question 8 of 10
What is the single responsibility principle?
Each file should contain only one class
Each class should have one clear purpose
Each method should take only one argument
// question 9 of 10
What is the purpose of VALID_STATUSES as a class attribute?
To prevent any instance from changing the status
To share a list of allowed values across all instances without repeating it
To define the order in which statuses are applied
// question 10 of 10
What happens if you forget to write self.name equals name in __init__?
The program raises a NameError immediately
The attribute is stored on the class instead
The value is stored as a local variable and lost after __init__ finishes
Submit Answers →