Both abstract class and interface are the major components of the Java language. Both these techniques are used for hiding the implementing part and exposing the functionality part of a program to its users. But both of these are different from one another:
Abstract Class | Interface |
---|---|
Only a single abstract class be get inherited by a class. | A class can inherit several interfaces. |
An abstract class provides the complete code or simply the details which need to be overridden. | The interface provides the signature rather than the code. |
It is comparatively faster than the interface. | It requires more execution time and hence slower than an abstract class. |
There you can provide the access specifier to the functions and properties of the abstract class. | There cannot be any access specifier to the interface, and hence everything is taken as a public. |
You can define fields and constants for abstract class. | You cannot define any fields within the interface. |
Keep W3schools Growing with Your Support!
❤️ Support W3schools