Introduction to Interface of Java

INTRODUCTION :
The Interface looks  like a class but it is not a class. Interface can have methods and variable just like the class,but the method are declared in interface by default abstract. Also, the variable declared in the interface are public, static and final by the default. The interface in Java is a mechanism to achieve full abstraction. 

==>> The class that implements interface must implement all the method of that interface. Java doesn't support  multiple inheritance. But using interface we can achieve this. As a class can implement more than one interface, multiple inheritance in Java use to interface.
 
 Definition :
      [visibility ]interface interfaceName;
[extends other interface ]
{
variables declarations;
Abstract method declaration ;
}
 
Interface is the keyword and InterfaceName is just a like a class name .
declared to variable are follows :          

 static final type variableName =value ;
 
Example of Interface : 
 

There are three types of interface :
 
(1) extending interface
 
(2) implementing interface
 
(3) Accessing interface.
 
Thanks you!!

Follow us here :

Comments