Interface body can contain default methods, static methods and abstract methods.
All methods are implicitly public.
Class can implement more than one interface.
Difference between Interfaces and Abstract classes - Java 8.0:
-->
Abstract class
|
Interface
|
with
abstract classes, you can declare fields that are not static and final, and
define public, protected, and private concrete methods.
|
With
interfaces, all fields are automatically public, static, and final, and all
methods that you declare or define (as default methods) are public.
|
You can
extend only one class, whether or not it is abstract
|
You can
implement any number of interfaces
|
Consider
using abstract classes if any of these statements apply to your situation:
|
Consider
using interfaces if any of these statements apply to your situation:
|
References:
No comments:
Post a Comment