Showing posts with label difference between interface and abstract class. Show all posts
Showing posts with label difference between interface and abstract class. Show all posts
Friday, April 23, 2010
what is the difference between interface and abstract class
what is the difference between interface and abstract class?
Answer: -
(1) An abstract class may contain complete or incomplete methods. Interfaces can contain only the Signature of a method but no body. Thus an abstract class can implement methods but an interface cannot implement methods.
(2) An abstract class can contain fields, constructors, or destructors and implement properties. An Interface cannot contain fields, constructors, or destructors and it has only the property's signature but no implementation.
(3) An abstract class cannot support multiple inheritances, but an interface can support multiple
Inheritance. Thus a class may inherit several interfaces but only one abstract class.
(4) A class implementing an interface has to implement all the methods of the interface, but the same is not required in the case of an abstract Class.
(5) Various access modifiers such as abstract, protected, internal, public, virtual, etc. are useful in Abstract Classes but not in interfaces.
(6) Abstract classes are faster than interfaces.
(7) One class can inherit multiple interfaces but it can't inherit multiple abstract classes
Subscribe to:
Posts (Atom)
+of+IMG_1821.jpg)