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

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
vsudakov
Posts: 4
Joined: Sat May 28, 2016 8:31 am
Contact:

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

Post 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.

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Yes, a static method can be hidden. But not overridden.

Splink
Posts: 1
Joined: Fri Jul 29, 2016 11:50 am
Contact:

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

Post 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
}

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

You are right. Fixed.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests