Classes, inheritance, polymorphism and OOP concepts at medium difficulty!
1. What is method overriding?
💡 Method overriding allows a child class to provide its own implementation of a method already defined in its parent class.
2. What is a constructor?
💡 A constructor is a special method automatically called when an object is instantiated to initialize its attributes.
3. What is "inheritance" in OOP?
💡 Inheritance allows a child class to acquire the properties and methods of a parent class, promoting code reuse.
4. What is "composition" in OOP?
💡 Composition builds complex objects by including instances of other classes as attributes — "has-a" relationship.
5. What is "polymorphism" in OOP?
💡 Polymorphism allows different objects to respond to the same method call in their own way — same interface, different behavior.
6. What is a "class" in OOP?
💡 A class is a blueprint or template that defines the attributes and methods that objects of that type will have.
7. What does the "private" access modifier do?
💡 Private members are only accessible within the class they are defined in — not from outside or subclasses.
8. What is "multiple inheritance"?
💡 Multiple inheritance allows a class to inherit from more than one parent class. Supported in Python but not Java.
9. What is an "abstract class"?
💡 An abstract class cannot be instantiated directly and may contain abstract methods that subclasses must implement.
10. What is an "interface" in OOP?
💡 An interface defines a contract — a set of methods that any implementing class must provide its own implementation for.
11. What is "method overloading"?
💡 Method overloading allows multiple methods with the same name but different parameter lists in the same class.
12. What is "abstraction" in OOP?
💡 Abstraction hides complex implementation details and exposes only the essential features of an object.
13. What is "encapsulation" in OOP?
💡 Encapsulation bundles data (attributes) and methods together inside a class and restricts direct access from outside.
14. What does "super()" do in OOP?
💡 super() is used to call a method or constructor from the parent (super) class within a child class.
15. What is a "static" method in OOP?
💡 A static method belongs to the class itself, not to instances. It can be called without creating an object.