<
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 Method Resolution Order?
The order Python searches for a method across parent classes
The order methods are defined inside a class
The order objects are created from a class
// question 2 of 10
What is the correct way to represent an empty class that will be filled later?
class MyClass: pass
class MyClass: return
class MyClass: None
// question 3 of 10
What is object composition preferred over?
Encapsulation when data needs to be public
Inheritance when the relationship is has-a rather than is-a
Polymorphism when types are known in advance
// question 4 of 10
What does __contains__ define?
The way the object is indexed
The behavior of the in operator on the object
The way the object iterates
// question 5 of 10
What does staticmethod decorator do?
Creates a method that belongs to the class but receives neither self nor cls
Creates a method that cannot be overridden
Creates a method shared by all instances
// question 6 of 10
What does vars(obj) return?
A list of the object's methods
The class attributes shared by all instances
A dictionary of the object's instance attributes
// question 7 of 10
What is composition in OOP?
One class containing an instance of another class as an attribute
A method that calls another method
A class inheriting from two parents
// question 8 of 10
What is loose coupling preferred in OOP?
Classes interact through well-defined interfaces rather than internal details
Classes share all attributes directly
Classes never call methods on each other
// question 9 of 10
What is the output of print(type(Animal()))?
The memory address of the object
The string representation of Animal
The class type of the object
// question 10 of 10
What does @property do in Python?
Prevents an attribute from being modified
Allows a method to be accessed like an attribute
Makes an attribute private
Submit Answers →