
About Question enthuware.ocajp.i.v7.2.1069 :
Moderators: Site Manager, fjwalraven
About Question enthuware.ocajp.i.v7.2.1069 :
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. 

-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1069 :
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:
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!
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
thank you for your feedback!
Who is online
Users browsing this forum: No registered users and 3 guests