You can, however, have a default method in a subinterface with the same signature as a static method of its super interface because a static method of an interface can only be called using that interface's name.
If you could explain this more closely.
Isn't the static method in the first case non overriding method if its static, and it can only be called using the interface name too.
Thanks
interface I{
default void dm(){ }
static void sm(){ }
}
interface SubI extends I{
static void dm(){ } //won't compile, error: dm() in SubI clashes with dm() in I
default void sm(){ } //valid
}
As far as why this rule exists, only the Java designers can tell. My guess is that if you have a static method in the subinterface, how will you then override the default method from the super interface in the sub interface if you wanted to?
If you like our products and services, please help us by posting your review here.
You need to use the official Oracle JDK and use its command line tools to compile your code because that is what the exam is based on.
You might want to check this article as well regarding usage of IDEs while preparing for the exam: https://enthuware.com/oca-ocp-java-cert ... cation-ide
If you like our products and services, please help us by posting your review here.