Chapter 5: Object-Oriented Programming - Python

Chapter 5: Object-Oriented Programming

Chapter 5: Object-Oriented Programming

Fill in the Blanks

1. A ________ is a blueprint for creating objects in Python.
Answer: class
2. The ________ method initializes an object’s attributes.
Answer: __init__
3. The process of one class inheriting from another is called ________.
Answer: inheritance
4. The term ________ refers to an object’s ability to take many forms.
Answer: polymorphism
5. Encapsulation restricts access to certain ________ of an object.
Answer: attributes
6. The self keyword represents the ________ instance of a class.
Answer: current
7. A ________ is an instance of a class.
Answer: object

True or False

1. Classes and objects are the core of Object-Oriented Programming.
Answer: True
2. The __init__ method is called manually to initialize an object.
Answer: False
3. A subclass inherits methods and attributes from a superclass.
Answer: True
4. Polymorphism allows methods to behave differently based on the object.
Answer: True
5. Encapsulation prevents all access to an object’s attributes.
Answer: False
6. Inheritance promotes code reuse.
Answer: True
7. The self keyword must always be explicitly passed when calling a method.
Answer: False

Match the Following

Concept Definition
Class Blueprint for objects
Object Instance of a class
Polymorphism Multiple forms
Encapsulation Restrict attribute access
Inheritance Code reuse
Answer: 1 → a, 2 → b, 3 → c, 4 → d, 5 → e

Answer in One Sentence

1. What is an object?
Answer: An object is an instance of a class containing data and methods.
2. What is the role of the __init__ method?
Answer: It initializes an object’s attributes when it is created.
3. What is encapsulation?
Answer: Encapsulation is the concept of restricting direct access to certain attributes of an object.
4. What is polymorphism in Python?
Answer: Polymorphism allows different classes to use methods with the same name but differing implementations.
5. What is inheritance in OOP?
Answer: Inheritance enables a subclass to reuse and extend the functionality of a superclass.

Comments

Popular posts from this blog

Index Class V - Excel - ICT

Interactive Worksheet - Excel-V True or False- Quiz

Interactive Worksheet - Excel-V Fill-in-the-Blanks Quiz