<
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 does it mean for a method to be inherited?
The method is copied into the child class file
The method runs twice when called
A child class can use the method without redefining it
// question 2 of 10
What is the risk of using a mutable default argument in __init__?
It is shared across all instances that do not pass their own value
It prevents the class from being subclassed
It raises a TypeError when the object is created
// question 3 of 10
What keyword is used to define a class in Python?
object
def
class
// question 4 of 10
What is inheritance in OOP?
A class that stores data in a file
A method that returns another object
A child class reusing attributes and methods from a parent class
// question 5 of 10
What is method resolution in Python?
Python caching method results for performance
Python searching for a method starting from the current class up through parent classes
Python sorting methods alphabetically before calling
// question 6 of 10
What does setattr(obj, 'name', value) do?
Creates a new method on obj
Sets the attribute name to value on obj
Raises an error if the attribute already exists
// question 7 of 10
What is the correct way to check if an object is an instance of multiple classes?
obj.type in [ClassA, ClassB]
isinstance(obj, (ClassA, ClassB))
type(obj) == ClassA or ClassB
// question 8 of 10
What is a data class in Python?
A class decorated with @dataclass that auto-generates __init__ and __repr__
A class that only stores data with no methods
A class that inherits from dict
// question 9 of 10
What is an object in OOP?
A variable that holds a list
An instance of a class
A function that returns data
// question 10 of 10
What is a property setter?
A method that returns the value of a private attribute
A method decorated with @attr.setter that validates before setting an attribute
A class attribute that cannot be changed
Submit Answers →