A class inherits from 2 interfaces and both the interfaces have the same method name as shown below. How should the class implement the drive method for both car and bus interface?



A class inherits from 2 interfaces and both the interfaces have the same method name as shown below...

Answer / Manoj Kumar Saini

When a class inherits from multiple interfaces with the same method name, it must provide separate implementations for each method in the class body. For example: class MyVehicle : public ICar, public IBus { ... void drive() { /* implementation for car */ } void drive() { /* implementation for bus */ } };

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOAD Interview Questions

What is the main difference between a class and an object?

1 Answers  


Explain what is object oriented programming language?

1 Answers  


Difference: 'uses', 'extends', 'includes'

7 Answers   Cognizant, Protech, TY, University,


What is the use of finalize method?

1 Answers  


Differentiate between data abstraction and encapsulation.

1 Answers  


What is virtual?

1 Answers   MindCracker,


What are base class, sub class and super class?

1 Answers  


Explain the term constructor

1 Answers  


What is virtual multiple inheritance?

1 Answers  


What is inheritance?

7 Answers   Protech,


Can an interface contain fields?

1 Answers  


What is the significance of encapsulation?

1 Answers  


Categories