interface variables are final and static by default and methods are public and abstract
- by sap
The question is why it's been decided to have variable as final and static and methods as public and abstract by default.
Is there any particular reason for making them implicit,variable as final and static and methods as public and abstract.
Why they are not allowing static method but allowing static variable?
We have interface to have feature of multiple inheritance in Java and to avoid diamond problem. But how it solves diamond problem,since it does not allow static methods.
In the following program, both interfaces have method with the same name..but while implementing only one we implement...is this how diamond problem is solved?
interface testInt{
int m = 0;
void testMethod();
}
interface testInt1{
int m = 10;
void testMethod();
}
public class interfaceCheck implements testInt, testInt1{
public void testMethod(){
System . out . println ( "m is"+ testInt.m );
System . out . println ( "Hi World!" );
}
}