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?
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 |
What is the main difference between a class and an object?
Explain what is object oriented programming language?
Difference: 'uses', 'extends', 'includes'
7 Answers Cognizant, Protech, TY, University,
What is the use of finalize method?
Differentiate between data abstraction and encapsulation.
What is virtual?
What are base class, sub class and super class?
Explain the term constructor
What is virtual multiple inheritance?
What is inheritance?
Can an interface contain fields?
What is the significance of encapsulation?