Questions and Answers Rated A+
How do you create an object of a class in Python?
✔✔By calling the class as if it were a function
What does inheritance allow you to do in object-oriented programming?
✔✔Create a new class based on an existing class
What is the purpose of the `super()` function in Python?
✔✔To call a method from the parent class
What is the difference between an instance variable and a class variable in Python?
✔✔An instance variable is specific to an object, while a class variable is shared by all objects of
the class
How do you access a class variable in Python?
✔✔By referencing the class name or an instance of the class
1
, What does the `@staticmethod` decorator do in Python?
✔✔Defines a method that doesn’t take `self` as a parameter
What is method overriding in Python?
✔✔When a subclass provides a specific implementation of a method already defined in the
superclass
What is polymorphism in object-oriented programming?
✔✔The ability to call the same method on different objects and have each object respond
differently
How do you call a method of a superclass in Python?
✔✔By using the `super()` function
What is an abstract class in Python?
✔✔A class that cannot be instantiated and serves as a blueprint for other classes
How do you define an abstract method in Python?
2