You have a base class Vehicle and a derived class Car. The base class has a method start(). If you want to add additional functionalities to the start() method specifically for the Car class without affecting the base class, what should you do?
- Use method overloading to create a new start() method in the Car class
- Use method overriding to override the start() method in the Car class
- Use multiple inheritance to inherit from both Vehicle and Car classes and create a new start() method in the Car class
- Use the super() keyword to extend the start() method in the Car class
In this case, you should use method overriding in the Car class. By using the super() keyword, you can extend the functionality of the start() method specific to the Car class without modifying the base class (Vehicle) method. This approach follows the principle of object-oriented programming and avoids redundancy.
Loading...
Related Quiz
- The ____ method in the unittest framework is used to clean up the resources used during the test.
- Which of the following is NOT a feature of Python?
- Which method is commonly used to send data from a web form to a Python back-end?
- Given a scenario where a system should notify a user if the storage space goes below 5% or above 95%. Which of the following combinations of operators will be suitable for the condition?
- How can you optimize the recursive Fibonacci function with dynamic programming?