Difference between interface and abstract class?
Hi friends this is one of most java interview question.So, we will see clear difference between
abstract class and interface.
you may visit this link to see clear view
1) If we don't know any thing about implementation just we have requirement specification then we should go for interface.
2) Every method present inside interface is by default public & abstract
3) The following modifiers are not allowed for interface methods, those are:
4) Every variable present inside interface is public, static final , bydefault wheather we are declare or not.
5) For the interface variables we can't declare the following modifiers, those are:
private, protected, transient, volatile
6) For the interface variables compulsary we should perform initialization at the time of declaration only
7) Inside interface we can't take instance& static blocks
8) Inside interface we can't take constructor.
1) If we are talking about implementation but not completly(partial implementation) then we should go
for abstract class
2) Every method present inside abstract class need not be public & abstract. we can take concrete
3) There are no restrictions for abstract class method modifier i.e, we can use any modifier
4) Abstract class variables need not be public, final static.
5) There are no restriction for abstract class variable modifiers
6) For the abstract class variables there is no restriction like performing initialization at the time of declaration.
7) Inside abstract class we can take static block & instance blocks
8) Inside abstract class we can take constructor.