OOP concepts.

Q1: What is a class?

A1: A class is a blueprint for creating objects. It defines methods (functions) and attributes (variables) that objects created from the class will have.


Q2: What is an object?

A2: An object is an instance of a class. It represents a specific entity created using the blueprint provided by the class.


Q3: What is instantiation?

A3: Instantiation is the process of creating an object from a class using its constructor (usually the __init__ method).


Q4: What is encapsulation?

A4: Encapsulation is the bundling of data (attributes) and methods (functions) together within a class and restricting direct access to some attributes to protect them from unintended modification.


Q5: What is inheritance?

A5: Inheritance is a mechanism where a class (child class) can inherit attributes and methods from another class (parent class), allowing code reuse and extension.


Q6: What is aggregation?

A6: Aggregation is a type of relationship where one class is associated with another, but the associated object can exist independently of the main object.


Q7: What is composition?

A7: Composition is a type of relationship where one class contains another class, and the contained object is dependent on the containing object.


Q8: What is polymorphism?

A8: Polymorphism allows objects of different classes to be treated as objects of a common parent class. It can be implemented using method overriding or interfaces.


Q9: What is method overriding?

A9: Method overriding occurs when a child class provides a specific implementation of a method already defined in its parent class.