OOPs Concepts with Python - Assessment Preparation
10. MCQs and Output-Based Questions
1. What is the main purpose of OOP?
a) Faster execution
b) Code reusability and modularity
c) Use of arrays
d) Reduced memory usage
Answer: b
2. Which concept of OOP allows code reuse?
a) Encapsulation
b) Polymorphism
c) Inheritance
d) Abstraction
Answer: c
OOPs Concepts with Python - Assessment Preparation
3. What is the output of the following code?
class A:
def greet(self):
print('Hello from A')
class B(A):
pass
b = B()
b.greet()
a) Hello from A
b) Hello from B
c) Error
d) No output
Answer: a
4. Which keyword is used to define a class in Python?
a) class
OOPs Concepts with Python - Assessment Preparation
b) object
c) define
d) def
Answer: a
5. Which method is automatically called when an object is created?
a) __delete__
b) __start__
c) __init__
d) __new__
Answer: c