Click here to Skip to main content
15,881,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can an abstract class inherits from an interface class ?I have 8 classes in my programme.Taxi,Subway and Buss inherit from abstract public transportation.and also Taxi and Buss inherit from vehicle which is an interface class.mid-buss and large-buss inherit from buss and limo inherits from Taxi.i need to say buss and taxi are also abstract classes.now we have an abstract class which inherits from interface so i have to implement the methods in the Taxi and Buss classes. is it correct to design something like above or not ?
Posted

1 solution

First off, an interface isn't a class - it can't contain any implementation at all.
An interface is a contract - "You agree to do this, and I'll let you in the club". This is nothing like a class, which says "I provide this, you can build upon it".

Can an abstract class include an interface in it's declaration? Yes.
But it has to include the interface properties and methods in the abstract class definition, or mark them as abstract - it can't just "leave them" to the concrete class to complete.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900