What is the difference between Abstract class and Interface. In what situations, they can be used ?

Showing Answers 1 - 2 of 2 Answers

Ranjit

  • Apr 25th, 2005
 

Interface must have an abstract method. 
Interface have no access modifers. 
Interface used to define the method and members. 
 
Abstract class is class. it has access modifiers. 
Abstract class cannot be instantiated but it can be derived.

  Was this answer useful?  Yes

Abstract Class:
A class that cannot be instantiated. An abstract class is a class that must be
inherited and have the methods overridden. An abstract class is essentially a
blueprint for a class without any implementation. In Abstract Class one method
should be abstract. Means we can implement the method or may be we can define
only in Abstract Class. In Abstract class we can give access modifier to the
methods, Properties etc.

Interface:
Interfaces, like classes, define a set of properties, methods, and events. But
unlike classes, interfaces do not provide implementation. They are implemented
by classes, and defined as separate entities from classes. In C# we can inherit
multiple Interface but we can inherit multiple Abstract class that is the main
difference between Abstract class and Interface. In Interface all method have by
default public access modifiers.


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions