Tagged: abstract class, C#, interface
- This topic has 0 replies, 2 voices, and was last updated 11 years, 6 months ago by
Pavan.
- AuthorPosts
- November 16, 2011 at 11:13 am #3043
Pavan
Memberdifference between abstract class and interface?
November 17, 2011 at 9:07 am #3048Site Default
MemberAbstract Class Vs Interface:
1. Interface and Abstract class both are used for written business logic.
2. There is no access specifires in Interface by default its public. Abstract class can have access specifires.
3. Both Interface and Abstract class are inherited by child classes.
4. In Interface we can declare only signature of methods. In Abstract class we can or can not declare body of method. But at least one method which have only signature not the body must be in Abstract class.
5. If all the method in Abstract class has no body then Abstract class will be like Interface.
6. Class which inherited Interface must be overriding all the methods of Interface. In Abstract it’s not necessary to override all the methods of Abstract class. If you will not override the abstract method in derive class the drive class must be mark as Abstract class.
7. You can inherit multiple interface in derived class but only one abstract class.November 18, 2011 at 8:27 am #3051Pavan
MemberThank you shobhit It help me a lot.
can you tell me how can i know in which condition we use Abstract Class and in which condition we use Interface. - AuthorPosts
- You must be logged in to reply to this topic.