The question is why it was decided to have the variable as final, and static, and methods as public and abstract by default.
Is there any special reason to make them implicit, variables both final and static, and methods - public and abstract.
Why don't they allow a static method, but allow a static variable?
We have an interface to have the multiple inheritance function in Java and to avoid the problem with diamonds. But how does he solve the diamond problem, since he does not allow static methods.
In the following program, both interfaces have a method with the same name .. but when implementing only one that we implement ... is this how the 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!" );
}
}
source
share