Abstract class and interface in java used to provide abstraction but there are lots of differences:
Abstract Class | Interface |
Abstraction(0 to 100%) | Abstraction(100%) |
Abstract class implemented by keyword ‘extends‘ | Interface implemented by using keyword ‘implements‘ |
Abstract class also can not be instantiated but can be invoked if the main() method exists. | Interface is completely abstract i.e can not create an instance of it. |
Abstract class can have abstract and non-abstract methods. | Interface methods are implicitly abstract and can not have an implementation(nobody) |
Abstract class allowed final, non-final and static variables also. | Interface allowed only final and static variables |
Abstract class members are private, protected, etc. | Interface members are public by default. |
Abstract class can extend only one class but implements multiple java interfaces. | Interface can extend other interfaces only. |
Abstract class is fast compare to interface | Interface is slow because it required extra indirection. |
See Also: Java Abstract Class Examples | See Also: Java Interface Examples |
See Also: