<
RHD
/>
Home
Blog
Quiz
Resources
About
Contact
// guest
▾
Login
Request Account
[ light ]
// Object-oriented programming
Object-oriented programming Quiz
// question 1 of 10
What does a double underscore prefix on an attribute do?
Applies name mangling making it harder to access directly
Makes the attribute completely inaccessible
Marks it as a constant
// question 2 of 10
What is method overriding?
Calling a method with different arguments
Defining two methods with the same name in one class
A child class redefining a method from the parent class
// question 3 of 10
What does __iter__ define?
The behavior that makes an object iterable in a for loop
The way an object is indexed with brackets
The way an object is compared during sorting
// question 4 of 10
What does super() do?
Calls the parent class method or constructor
Deletes an inherited method
Creates a new instance of a class
// question 5 of 10
What keyword is used to define a class in Python?
def
object
class
// question 6 of 10
What is inheritance in OOP?
A method that returns another object
A child class reusing attributes and methods from a parent class
A class that stores data in a file
// question 7 of 10
What happens when you assign a value to a class attribute through an instance?
A new instance attribute is created that shadows the class attribute
The class attribute is modified for all instances
A TypeError is raised
// question 8 of 10
What is an object in OOP?
A variable that holds a list
A function that returns data
An instance of a class
// question 9 of 10
What happens if __str__ is not defined on a class?
Python raises a TypeError when print is called
Python uses the class name as the string
Python falls back to __repr__ and then to the default memory address representation
// question 10 of 10
What does __str__ define?
The way two objects are compared
The string representation returned by print()
The length of the object
Submit Answers →