We help IT Professionals succeed at work.

Can an Abstract Class Inherit Another Abstract Class?

pointeman
pointeman asked
on
I know a class can inherit multiple Interfaces but can only inherit one Base (abstract) class. I've read articles of coders complaining about not being able to inherit more than one base class. I'm not a .NET engineer so I raise the question about 'chaining' abstract classes together. I'm guessing the answer is no to eliminate naming ambiguity.

Q. Can an Abstract Class Inherit Another Abstract Class?
Comment
Watch Question

Yes an abstract class can inherit from another abstract class but all the methods of the base abstract class must be abstract.
MisbahSr. Software Engineer

Commented:
yes .
MisbahSr. Software Engineer
Commented:
i dont think the methods of the base class has to be all abstract, that is true for interfaces not abstract classes , you can try it :)
@Dr-Hussain  ahaha .. well i have to say i answered for Java, being C# an almost exact copy of Java i thought it would be the same :-)
MisbahSr. Software Engineer

Commented:
@mandriluy: yes they are almost the same :)

Author

Commented:
Okay, just wondering because digging through some MSDN info concerning the Button control. I didn't see any abstract classes inherting other abstract classes. Instead, inheriting Interfaces.
MisbahSr. Software Engineer

Commented:
yes, it is unusual, but if you will open Visual Studio , you can try it .. I did that also to confirm my answer .
Senior Developer
Commented:
The answer is yes, of course. But...

OK, ask yourself: what is the point for inheriting an abstract class by an abstract class?
Inheriting interfaces is a bit different.

really, I can probably imagine why one abstract class would inherit another but it would be very rare case...
anarki_jimbelSenior Developer

Commented:
This article is pretty good. Though does not answer the question :)

http://www.codeproject.com/KB/cs/jmabstractclasses.aspx