Difference between abstract class and interface
by
admin
·
Published
· Updated
Number |
Abstract Class |
Interface |
1 |
Abstract class is defined with keyword abstract |
Interface is defined with keyword interface |
2 |
Abstract class can be consider as data type |
Interface can be consider as data type |
3 |
In abstract class data member can be anything i.e int or float or String etc. |
In interface data member is automatically public static and final |
4 |
We can't create a object of Abstract class |
We can't create a object of interface |
5 |
Abstract class can have Constructor |
Interface can't have Constructor |
6 |
Default access modifier of any method in abstract class is default |
Default access modifier of any method in interface is public |
7 |
Abstract class can have method with any access modifier i.e method can be public or private or protected or default etc |
Interface has methods with only public access modifier |
8 |
Any class can extend abstract class using keyword extends |
Any class can implements interface using keyword implements |
9 |
Abstract class can extend any other class |
Interface can't inheritate any class even not object class |
10 |
Multiple inheritance is not possible |
Multiple inheritance is possible |
11 |
When you know implementation of few methods then go for abstract class |
If you don't know implementation of any method then go for interface |
12 |
Abstract class can have abstract methods ,static methods as well as non-static methods |
Interface can have abstract methods as well as static methods but not non static methods |