What is the primary reason to use method overriding in object-oriented programming?
- To create a new method
- To extend a class's functionality
- To hide a method's implementation
- To improve code readability
The primary reason to use method overriding is to hide a method's implementation in the base class and provide a specialized implementation in the derived class. This allows for polymorphism and abstraction.
Loading...
Related Quiz
- Imagine you have a Circle class where you want the radius to always be non-negative. Which approach would you use to ensure this while still allowing direct assignment like circle.radius = 5?
- Which of the following is not a valid list comprehension?
- Which method can be used to get the value for a given key from a dictionary, and if the key is not found, it returns a default value?
- In Pandas, how can you filter the rows of a DataFrame where the value in a specific column is greater than a threshold?
- How can default argument values be used to achieve method overloading in Python?