Question:
How different are interface and abstract class in .Net?
Answer:
Abstract classes can not be instantiated it can have or cannot have abstract method basically known as mustinherit as the methods are static in nature
where interfaces are the declaration and r defined where they are called used for dynamic methods Source: CoolInterview.com
Interface needs to be implemented,abstract class has build in implementation. Source: CoolInterview.com
Answered by: pushkar prabhu | Date: 2/29/2008
| Contact pushkar prabhu
1.A class implementing an interface must implement all of the methods defined in the interface, while a class extending an abstract class need not implement any of the methods defined in the abstract class. Additionally, a class extending an abstract class can implement an infinite number of it's own methods. 2.in abstract class we can put sharable code, but that is not possible in case of interface. 3.We can use interface as marker, ( we can use abstract class also as abstract but then we can't extends any other class, so it is better always use interface as marker). Source: CoolInterview.com
Answered by: Kunal Karekar | Date: 4/15/2008
| Contact Kunal Karekar
An abstract class is a special kind of class which can not be instantiated. An abstract class can provide complete, default code and/or just the details that have to be overridden. An interface has no implementations.It only has definition of methods.A class can inherit more than one interface but a class can inherit only one abstract class. Source: CoolInterview.com
Answered by: Isha Ahuja | Date: 11/3/2008
| Contact Isha Ahuja
An abstract class is one that cannot be instantiated which can contain either abstract methods or non abstract methods.also it can contain methods with any type of access specifiers. Coming to Interface is a one which is contract based one. ie contrast means its methods or properties must be compulsorily implemented. also the access specifier should be public. Source: CoolInterview.com
Answered by: Yuvaraj | Date: 4/1/2009
| Contact Yuvaraj
abstract class come into inheritance chain,where interface does not come in inheritance chain. abstract class can have concreate methods,interface doesnot have methods Source: CoolInterview.com
Answered by: tanuja | Date: 9/30/2009
| Contact tanuja
abstract class contains atleast one abstract method but interface contains all methods as abstract in nature Source: CoolInterview.com
Answered by: biswa | Date: 5/11/2010
| Contact biswa
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|