An interface in programming (especially in Java, C#, etc.
) is like a contract or a
blueprint.
It only defines what methods or properties a class should have, but not how they
work.
It has method declarations, not method bodies.
A class that "implements" the interface must provide the body (implementation) for
all those methods.
Nested interfaces (interfaces declared inside a class or another interface) can be:
o public
o protected
o private
o default (package-private)
Methods are Implicitly public.
They must be public, as interface methods cannot have less visibility than the
interface itself an implementation).
default methods allow classes to inherit a method implementation
When an interface extends another, it inherits all the abstract methods of the parent
interface, and any class implementing the child interface must provide an
implementation for those methods.
An interface cannot implement another interface. Only a class can implement an
interface.
An abstract class that implements an interface can leave the method
implementations to its subclasses. It doesn’t need to implement all methods itself.
If the interface has a default method (added in Java 8), the class doesn't have to
implement that method. The class can choose to use the default implementation
provided by the interface.
Static variables in interfaces are implicitly public, static, and final
Static methods in an interface are implicitly public.
They are not inherited by classes that implement the interface. A class cannot
override static methods from an interface.
Calling static method directly from the interface