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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *