Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1481 :

Posted: Sat May 28, 2016 1:44 pm
by vsudakov
Hello.

From explanation on the first option:
You cannot override a static method with a non-static method and vice-versa.
Static method can be hidden by instance method in inheritance of interfaces, isn't it?
For examples this is compiled well:

public interface I1 {
static void m1() { }
}

public interface I2 extends I1 {
default void m1(){ }
}

Thanks.

Re: About Question enthuware.ocajp.i.v8.2.1481 :

Posted: Sat May 28, 2016 8:25 pm
by admin
Yes, a static method can be hidden. But not overridden.

Re: About Question enthuware.ocajp.i.v8.2.1481 :

Posted: Sun Aug 21, 2016 11:30 am
by Splink
There is a mistake in explanation to answer number one.
Instead of this:
interface I{
public default void valid(){ }
public static void invalid(){ }
}
interface I2 extends I{
public static void valid(){ }//this is ok
public default void invalid() { }//WILL NOT COMPILE
}
It should be like this:
interface I{
public default void valid(){ }
public static void invalid(){ }
}
interface I2 extends I{
public static void valid(){ }//WILL NOT COMPILE
public default void invalid() { }//this is ok
}

Re: About Question enthuware.ocajp.i.v8.2.1481 :

Posted: Sun Aug 21, 2016 11:54 am
by admin
You are right. Fixed.
thank you for your feedback!