About Question enthuware.ocajp.i.v7.2.1069 :

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
ByteByteByte

About Question enthuware.ocajp.i.v7.2.1069 :

Post by ByteByteByte »

The explanation for option 4 says that 'final only means that subclasses cannot override it' but the method also has the static modifier which means it can not be overridden. :shock:

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

Re: About Question enthuware.ocajp.i.v7.2.1069 :

Post by admin »

The purpose of final is to prevent overriding. For example, if you try to compile the following code that tries "override" as final static method, the error message also calls it overriding:

Code: Select all

class X{
 public final static void m1(){ }
}
public class Test extends X
{
 public final static void m1(){ }
}

Test.java:6: m1() in Test cannot override m1() in X; overridden method
 is static final
 public final static void m1(){ }
                          ^
1 error
But the right terminology in case of a static method is "shadowed". The explanation should be modified to avoid such confusion.

thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests