| Author: Kr. Hemendra Singh Shaktawat 06 Sep 2006 | Member Level: Gold | Rating:  Points: 2 |
Hi,
Its on need basis than the choice.
Abstract Class is a fullfedge class with most common functionality and property so you can not make an object of an Abstract class. Example Human is Abstract and Ram is derived from Human.
Ok Now Interface is a class like implementation that has only function bodies. We use Interface to achieve multiple inheritance as multiple inheritance is not directally supported in C#.
Hope this helps.
Good Luck
Hemendra Singh Shaktawat
Mindfire Solutions www.mindfiresolutions.com
|
| Author: tapan dalai 07 Sep 2006 | Member Level: Silver | Rating:  Points: 2 |
1) yes interface act as blueprint for a class. 2)go through my document bellow...u can get aneswar. 3)yes
Here are some recommendations to help you to decide whether to use an interface or an abstract class to provide polymorphism for your components.
If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface. If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes. If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.
If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members
tapan dalai tapan.dalai@gmail.com cell 9880383372
|
| Author: DotNetGuts (DNG) 11 Sep 2006 | Member Level: Diamond | Rating:  Points: 2 |
Refer it for better understanding 1) http://www.dotnetspider.com/kb/Article2293.aspx 2) http://www.dotnetspider.com/kb/Article2306.aspx
DotNetGuts (DNG) DotNetGuts Blog
|
| Author: Mrunal Brahmbhatt 21 Nov 2007 | Member Level: Bronze | Rating:  Points: 2 |
Both Interface and Abstract Class are different from each other do not mix up.
Situation where functionality may add/remove "Abstract Class" is best solution.
Eg. Creating Base Classes,Creating Base for your project where functionality may be added or remove or can be override if needed.Mostly common task are move to base class and if required than can be overrided.
Situation where we have fix requirement "Interface" is best solution.
Eg. Plugin .Where Pluging can be loaded dynamically and executes its functionality. Thus that Plugin must follow or implement certain functionality.
Its concept of Plug and Adapter.
|
| Author: asdf 08 Aug 2008 | Member Level: Silver | Rating:  Points: 0 |
• Abstract Class Cannot be instantiated. Must be inherited and its methods should be overridden. It have some concreate methods. Access modifiers allowed.
• Interface Have definition of a method not implementation. (implement through class) Multiple inheritance possible through Interface only Only Public Access modifier only allowed. Defaultly Public No need of virtual overridden. It’s used for to define a set of properties, methods and events.
|
| Author: Bunty 18 Sep 2008 | Member Level: Diamond | Rating:  Points: 4 |
Hi,
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.
Regards S.S.Bajoria
Thanks & Regards S.S.Bajoria
|
| Author: Bunty 23 Sep 2008 | Member Level: Diamond | Rating:  Points: 6 |
Hi,
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.
Regards S.S.Bajoria
Thanks & Regards S.S.Bajoria
|
| Author: Miss Meetu Choudhary 23 Oct 2008 | Member Level: Diamond | Rating:  Points: 6 |
Hi,
Interface
A standard way of calling routines and passing data structures. For example, the interface between two layers of code might be expressed in terms of routines that pass and return a particular data structure. Linux's VFS is a good example of an interface.
An interface in the programming language is an abstract type that is used to specify an interface (in the generic sense of the term) that classes must implement. Interfaces are declared using the interface keyword, and may only contain method signatures and constant declarations (variable declarations which are declared to be both static and final). An interface may never contain method definitions.
As interfaces are implicitly abstract, they cannot be directly instantiated. Object references may be specified to be of an interface type; in which case they must either be null, or be bound to an object which implements the interface.
The keyword implements is used to declare that a given class implements an interface. A class which implements an interface must either implement all methods in the interface, or be an abstract class.
One benefit of using interfaces is that they simulate multiple inheritance.
for more information please visit
http://en.wikipedia.org/wiki/Interface_(Java)
== Thanks and Regards Meetu Choudhary
Thanks and Regards Miss Meetu Choudhary (Site Coordinator) Go Green Save Green My Profile on Google
|
| Author: Miss Meetu Choudhary 21 Feb 2009 | Member Level: Diamond | Rating:  Points: 6 |
Abstract Class:
The class which contains the common features of components of several classes, but cannot it be instantiated by itself. It represents an abstract concept for which there is no actual existing expression. For instance, "Vegetation" is an abstract class - there is no such real, real thing as generic vegetation. Instead, there are only instances of vegetation, such as mango tree and rose plant, which are types of vegetation, and share common characteristics, such as having leaves and stem in at least part of the lifecycle.
SO in software engineering, an abstract class is a class in a nominative type system which is declared by the programmer, and which has the property that it contains members which are also members of some declared subtype. In many object oriented programming languages, abstract classes are known as abstract base classes, interfaces, traits, mixins, flavors, or roles. Note that these names refer to different language constructs which are (or may be) used to implement abstract types.
We can also say that abstract class is : -- A class which is used only as an ancestor and is never instantiated.
In other word a concrete definition will say that
A type of class with pure virtual member functions and one or more methods that are declared but not implemented, that behaves as a base class but prohibits the instantiation of any members of that class. i.e. It has a complete interface but only a partial implementation It is used to take advantage of inheritance yet prohibiting the generation of objects that are not completely defined. Concrete subclasses of an abstract class are required to flesh out the implementation by overriding the abstract methods.
Thanks and Regards Miss Meetu Choudhary (Site Coordinator) Go Green Save Green My Profile on Google
|