Thursday 8 May 2014

Difference between Interface and Abstract class





1)if we dont know anything about  implementation, just we have only requirement specification. then we go for interface.

If we know the implmentation, but not fully. We know the partial implementation then we go for Abstract class.


2) By default All method in interface is public and abstract, even its not declared too.So interface itself 100% abstract class.

methods in abstract class may have abstract or concrete.


3) we cannot use follwing access modifiers in interface Private,protected,final,static,synchronized,native,strictfp. That means interface only allowed public and abstract.

But there is no restriction for using access modifiers in Abstract class.

4) All the methods in interface should override in subclass.

If sub class is not override interface means is called abstract class

No comments:

Post a Comment