An Abstract class has abstract methods. An Abtsract class can not be instanitiated directly. All the abtract methods are implemented in the derived class. There is no multiple inheritance here.
Interface class also has abstract methods and all of them are public. You can have multiple inheritance with Interfaces.
In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.
sabir
Jan 21st, 2006
the interface will have all absract method the absract will contain one or more absract method all the methods the interface has to be implemented but it is not req to implemne t all the methods in absract class
Arivoli
Feb 24th, 2006
Interface :
1. All the methods in the interface are abstract. 2. We can achieve multiple inheritance through interface. 3. All the methods in the interface should be without Access modifier. Implicitly public.
Abstract class:
1. Abstract class may contain abstract method and non-abstract method. 2. We can achieve only single inheritance and multi-level inheritance. 3. Abstract methods have Access modifiers.
An Interface is created/used when we have different types of objects while an abstract class is used when there is a single root hierarchy.
Devaraja Rao, Ambekar
Aug 30th, 2006
Abstarct class is like normal class with 2 specials. 1. It can not be instanciated, 2. It can have abstarct functions. Abstract class is used in inheritance as super class, where some common implementation is requried.
Example is Thread class
interface is different type than class. All the members are public and no implementation is allowed. Interfaces are used for 1. For declaring project level constants, because all variables public final and static. 2. In delegation pattern for providing flexibilty of implementation.
1. Abstract class may contain abstract method and concrete method(means having own implemantion). 2. Abstract methods have Access modifiers(Public, protected,internal etc).
Interface :
1. All the methods in the interface are abstract. 2. We can achieve multiple inheritance through interface. 3. Donot have access Modifiers by default is PUBLIC
Priestly George Varghese
Oct 9th, 2007
Interface
All methods are abstract and there is no implementation.
No access modifiers are allowed.
Interfaces are essentially having all method prototypes no definition
We can achieve multiple inheritance through interface
Abstract class
Some methods can be concrete.
They have access modifiers
Contain method definitions also.
We can achieve only single inheritance and multi-level inheritance
It can not be instantiated
Besides the rules difference between of interfaces and abstract class, keep this also in mind.
Abstract classes promotes high cohesion, while interfaces provides loose coupling. High cohesion and loose coupling are considered as the best design strategy for complex software designs.
What is difference in an Abstract Class and an Interface.
Abstract class can contain method definations also.
Interfaces are essentially having all method prototypes no definition
In short Interface is a abstract class having all methods abstract
Related Answered Questions
Related Open Questions