10 November 2020

Abstraction vs Interface

Abstract-class Interface
To avoid independence For future enhancement
Can have abstract and non-abstract methods Only abstract methods.
Java 8 onwards it can have default and static methods also
Can have constructor Not possible
Member of interface can be static Not possible
Doesn't support multiple inheritance Supports multiple inheritance
Can have final, non-final, static and non-static variables Only static and final variables
Can provide the implementation of interface It is not possible to provide the implementation of abstract class
Can extend another Java class and implement multiple Java interfaces Not possible
Fast Slow

No comments:

Post a Comment

Most views on this month