Unit 3: OOP concepts - Subjective Questions

ECAP776 • Practice Questions with Detailed Answers

20 questions

1

Define object-oriented programming. Explain its major features in the context of Python.

2

Distinguish between a class and an object with a suitable Python example.

3

Explain the purpose of the __init__() method and the self parameter in Python classes.

4

Describe instance attributes, class attributes, instance methods, class methods, and static methods.

5

Define encapsulation and explain why it is important in object-oriented programming.

6

Explain public, protected, and private members in Python. How does Python's approach differ from strict access control?

7

What is name mangling in Python? Describe its purpose, behavior, and limitations.

8

Explain how properties support encapsulation in Python. Illustrate your answer with validation of an attribute.

9

Compare direct attribute access, getter and setter methods, and the property mechanism in Python.

10

Design an encapsulated BankAccount class that validates deposits and withdrawals. Explain how the class preserves its invariants.

11

Define inheritance and explain its advantages and possible disadvantages.

12

Describe single, multilevel, hierarchical, multiple, and hybrid inheritance with Python-oriented examples.

13

Explain method overriding in Python and show how it enables runtime polymorphism.

14

What is the purpose of super() in Python inheritance? Explain its use in constructors and overridden methods.

15

Explain method resolution order in Python. How does it resolve ambiguity in multiple inheritance?

16

Describe the diamond problem in multiple inheritance and explain how Python handles it.

17

Distinguish between method overriding and method overloading. How is overloading commonly simulated in Python?

18

Compare inheritance and composition. State when each technique should be preferred.

19

Explain how encapsulation and inheritance interact. What risks arise when a subclass accesses a parent's internal state directly?

20

Develop a Python class hierarchy for employees that demonstrates inheritance, encapsulation, overriding, and polymorphism. Explain the design.