Answer
Interface |
Abstract Class |
|---|---|
| 1. If we don’t know anything about implementation just we have requirement specification, then we should go for interface. | 1. If we are talking about implementation but not completely (partial implementation) then we should go for abstract class. |
| 2. Every method present inside interface by default public & abstract. | 2. Every method present inside abstract class need not public & abstract we can take concrete method also. |
| 3. The following modifiers are not allowed for interface methods private, protected, strictfp, static, native, synchronized.. | 3. There are no restrictions for abstract class methods i.e we can use any modifier |
| 4. Every variable present inside interface is public static final by default weather we are declare are not. | 4. Abstract class variable need not be public static final |
| 5. For the interface variable we can’t declare the following modifiers private, protected, transient, volatile.. | 5. There are no restrictions for abstract class variable modifier |
| 6. For interface variable compulsory we should perform initialization at the time of declaration only. | 6. For abstract class variable it is not required to perform initialization at the time of declaration. |
| 7. Inside interface we can’t declare instance & static blocks; otherwise we will get compile time error. | 7. Inside abstract class we can declare instance & static blocks. |
| 8. Inside interface we can’t declare constructors | 8. Inside abstract class we can declare constructors, which will be executed at the time of child class object creation |