Difference between abstract class and interface

NumberAbstract ClassInterface
1Abstract class is defined with keyword abstractInterface is defined with keyword interface
2Abstract class can be consider as data typeInterface can be consider as data type
3In 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
4We can't create a object of Abstract classWe can't create a object of interface
5Abstract class can have ConstructorInterface can't have Constructor
6Default access modifier of any method in abstract class is defaultDefault access modifier of any method in interface is public
7Abstract class can have method with any access modifier i.e method can be public or private or protected or default etcInterface has methods with only public access modifier
8Any class can extend abstract class using keyword extendsAny class can implements interface using keyword implements
9Abstract class can extend any other classInterface can't inheritate any class even not object class
10Multiple inheritance is not possibleMultiple inheritance is possible
11When you know implementation of few methods then go for abstract classIf you don't know implementation of any method then go for interface
12Abstract class can have abstract methods ,static methods as well as non-static methodsInterface can have abstract methods as well as static methods but not non static methods

You may also like...

Leave a Reply