Forums » .NET » .NET »
What is the difference between abstract and interface?
Posted Date: 02 Aug 2008 Posted By:: Vikranth Member Level: Silver Member Rank: 0 Points: 1
Please give me the clear points.
|#275466 Author: Kumar Velu Member Level: Gold Member Rank: 121 Date: 02/Aug/2008 Rating: Points: 6|
1. Abstract Class Can contain Abstract Methods and Non-
2. When a Non-Abstract Class is Inherited from an Abstract
Class, the Non-Abstract Class should provide all the
implementations for the inherited Abstract Method.
1. Interface is nothing but Pure Abstract Class ie
Interface can contain only the function declaration.
2. All the members of the interface are Public by Default
and you cannot provide any access modifiers.
3. When a class is inherited from the interface, the
inherited class should provide actual implementations for
the inherited members.
|#275469 Author: Vidhya Member Level: Gold Member Rank: 0 Date: 02/Aug/2008 Rating: Points: 6|
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.
another key difference between abstract class and interface is that , in abstract class we can put sharable code, but that is not possible in case of interface.
Another key difference between abstract class and interface is that,
We can use interface as marker, ( we can use abstract class also as abstract but then we can't extends any oter class, so it is better always use interface as marker)
|#275511 Author: Ultimaterengan Member Level: Gold Member Rank: 11 Date: 02/Aug/2008 Rating: Points: 2|
1)All The Methods are Abstract.its a pure Abstract Class
2)There No Access Modifier by Default : Public
3)There is No implementtation
1)Abstract Class can have Abstract Methods and Non-Abstract Methods.
2)All The Access Modifiers Allowed in Abstract Class
3)implementtation Allowed in Abstract Class
i hope this may help u.
Thanks & Regards
Nothing is mine ,Everything is yours!!!
|#275518 Author: chandramohan Member Level: Gold Member Rank: 214 Date: 02/Aug/2008 Rating: Points: 6|
Abstract class is a class which contain one or more abstract methods, which has to be implemented by sub classes. Inteface is a Java Object containing method declaration and doesn't contain implementation. The classes which have implementing the Interfaces must provide the method defination for all the methods.2. Abstract class is a Class prefix wtih a abstract keyword followed by Class definaton. Interacace is a Interface which starts with interface keyword.3. Abstract class contatins one or more abstract methods. where as Interface contains all abstract methods and final declarations.4. Abstract class contains the method defination of the some methods. but Interface contains only method declaration, no defination provided.5. Abstract classes are useful in a situation that Some general methods should be implemented and specialization behaviour should be implemented by child classes. Interafaces are useful in a situation that all properties should be implemented we can use this scenario
|#275688 Author: Ashok Khanna Member Level: Gold Member Rank: 265 Date: 04/Aug/2008 Rating: Points: 5|
Differences between Abstract Class and Interface :
* can contain access modifiers for subs,properties and functions.
* a class may inherit only one abstract class.
* can contain defined fields and constants
* cannot contain access modifiers for subs,properties and functions.
* a class may inherit several interfaces.
* cannot contain any defined fields and constants.
Please rate this post, if it is useful for you.
Thanks & Regards
|#277006 Author: RobinHood Member Level: Gold Member Rank: 44 Date: 06/Aug/2008 Rating: Points: 4|
Verify this link..This may help u..
Nothing is illegal, Until You Get Caught
|#289735 Author: Raghav Member Level: Gold Member Rank: 184 Date: 30/Aug/2008 Rating: Points: 5|
Before putting any question in the forum, please search for it if the answer is already available in dotnetspider website. Because so many people are asking the same question about interface and abstract class. Please do not repeat the same questions again and again. There is a searchbox at the top right of the dotnetspider website. You can search for the answer by using that search box. If you do not find any answer, then you can post the question in the forum.
|#295816 Author: Bunty Member Level: Gold Member Rank: 15 Date: 16/Sep/2008 Rating: Points: 4|
Interfaces are similar to abstract classes.However,interface represent the highest level of abstraction in object-oriented programming.This is because all the methods in an interface are abstract and do not have implementation.In contrast,the abstract classes that are created using Abstract keyword might contain a method that has a body.
Thanks & Regards
|#298567 Author: Bunty Member Level: Gold Member Rank: 15 Date: 22/Sep/2008 Rating: Points: 6|
Following are the difference between abstract and interface,
1>Abstract class having method declaration as well as method method definition whereas interface having method declaration only.
2>Abstract class are known as partial abstract class whereas interface is known as fully abstract class.
3>Abstract class features we have to inherit to the child class whereas interface features we have to implement in the child classes.
4>Abstract class support access specifiers whereas interface doesn't support access specifiers.
5>Abstract class have normal variable as well as constant variable whereas interface have only constant variables.
6>We can write constructor in abstract class whereas we can't write constructor in interface.
Thanks & Regards
|#307363 Author: Miss Meetu Choudhary Member Level: Gold Member Rank: 14 Date: 16/Oct/2008 Rating: Points: 6|
Following are the differences
• Interface contains methods that must be abstract; abstract class may contain concrete methods.
• Interface contains variables that must be static and final; abstract class may contain non-final and final variables.
• Interface can "extends" another interface, abstract class can "extends" another class and "implements" multiple interfaces.
• Interface is absolutely abstract; abstract class can be invoked if a main() exists.
• Interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces.
• Members in an interface are public by default; abstract class may contain non-public members.
• Interface is used to "implements"; whereas abstract class is used to "extends".
• Interface can be used to achieve multiple inheritance; abstract class can be used as a single inheritance.
Thanks and Regards
Thanks and Regards
Miss Meetu Choudhary (Site Coordinator)
Go Green Save Green
| ||This thread is locked for new responses. Please post your comments and questions as a separate thread.|
If required, refer to the URL of this page in your new post.
Active MembersTodayLast 7 Daysmore...
Talk to Webmaster Tony John