
Can Any one Give the exact program explanation for Interface in java? and want to know why they used interface instead of multiple inheritance? Thanks in advance

An interface is one which has abstract methods(not defined just declared)and static or non static variables.Any class can implement(inherit)the interface and make use of the methods(functions) and variables within it.
Here is an example where we have defined an interface and implements its methods (which are declared in interface) int the class.
interface Ex{
int getData();
void setData(int x);
}
class InterfaceExample implements Ex
{
int x;
public int getData(){
return x;
}
public void setData(int x){
this.x=x;
}
public static void main(String[] args)
{
InterfaceExample ex=new InterfaceExample();
ex.setData(5);
int num=ex.getData();
System.out.println(num);
}
}
Actually java does not support multiple inheritance. The reason behind this is when we extends more than one class, JVM get some ambiguous problem and will get confused as which method it will take.It creates complexity.Therefore java uses Interface.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.