WorksheetsPython Object-Oriented Programming Quiz
Total questions: 10
Worksheet time: 5mins
What does a class represent in Python?
A function
A blueprint for objects
A variable
A module
What is an object in Python?
A block of code
An instance of a class
A data type
A loop
Which method is called automatically when an object is created?
__start__
__create__
__init__
__object__
What does self refer to in a Python class method?
The class itself.
The current instance of the class.
A global variable.
A static variable.
How do you create an object (instance) of a class named MyClass?
obj = MyClass()
obj = new MyClass
MyClass.create_object()
instance = MyClass.object
What is an instance variable in a Python class?
A variable shared among all instances of a class.
A variable defined outside the class.
A variable specific to an instance of a class.
A variable used for method overloading.
Which of the following core principle of Object-Oriented Programming (OOP) that involves bundling data and methods that operate on that data into a single unit (class)?
Inheritance
Polymorphism
Encapsulation
Abstraction
What is the process of creating a new class based on an existing class called?
Polymorphism
Encapsulation
Inheritance
Abstraction
Which of the following best describes how Python handles "private" attributes within a class?
It uses the private keyword to declare them.
It uses a single underscore prefix (_) to make them truly inaccessible.
It uses a double underscore prefix (__) as a naming convention to indicate intended privacy and trigger name mangling.
Python does not support private attributes; all members are public
Which of the following does not correctly create an object instance?
my_dog=Dog("Lego")
puppy= MyDog()
jammie = His-Dog()
dog=Her_Dog()
