<
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 __init__ return?
The newly created object
Nothing — it always returns None
A boolean indicating success
// question 2 of 10
What is the difference between is and equals equals when comparing objects?
They are identical in all cases
is is faster but less accurate
is checks identity and equals equals checks equality as defined by __eq__
// question 3 of 10
What is a property setter?
A method decorated with @attr.setter that validates before setting an attribute
A class attribute that cannot be changed
A method that returns the value of a private attribute
// question 4 of 10
What is polymorphism?
The same method name behaving differently depending on the object
A class that has multiple constructors
A method that accepts any number of arguments
// question 5 of 10
What is self in a method?
A keyword that creates a new class
A reference to the current object
A built-in function for initialization
// question 6 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 7 of 10
What does @property do in Python?
Allows a method to be accessed like an attribute
Prevents an attribute from being modified
Makes an attribute private
// question 8 of 10
What does staticmethod decorator do?
Creates a method shared by all instances
Creates a method that belongs to the class but receives neither self nor cls
Creates a method that cannot be overridden
// question 9 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 10 of 10
What is an attribute?
A variable that belongs to an object
A function defined inside a class
A class-level constant
Submit Answers →