|
Interface |
Abstract Class |
1 |
If we don’t know about the
implementation, just we have
requirement specification then we should go for Interface |
If we are talking about
implementation but not completely (partial
implementation) then we should go for Abstract
class. |
2 |
Inside interface every
method is always public and abstract whether
we are declaring or not. Hence interface is also considered as 100% pure
Abstract class. |
Every method present in Abstract
class need not be public and Abstract. In addition to abstract methods we can take concrete methods also. |
3 |
We can’t declare interface
method with the following modifiers. Publicàprivate, protected Abstract->final, static,
synchronized, native, strictfp |
There are no restrictions on Abstract class method modifiers. |
4 |
Every variable present inside interface is
always public, static and final. |
The variable present inside
Abstract class need not be public static and final. |
5 |
For interface variable, we must perform initialization at the
time of declaration otherwise we will get
compile time error. |
For Abstract class variables, it
is not required to perform
initialization at the time of declaration. |
6 |
Inside interface we can’t
declare instance and static blocks, otherwise we will get compile error. |
Inside Abstract class we can
declare instance and static blocks. |
7 |
Insider interface we can’t declare constructors. |
Inside Abstract class we can declare constructor, which will be executed at the time of
child object creation. |