aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overriding " Watch "Overriding " New topic
Author

Overriding

Jeet Jain
Ranch Hand

Joined: Sep 01, 2011
Posts: 53


I dont understand why "static final" prevent compilation?
Jeet Jain
Ranch Hand

Joined: Sep 01, 2011
Posts: 53
08. is an instance method and 04. is static. Its not overriding it. Just hiding it, right?
gihan dissanayaka
Greenhorn

Joined: Sep 03, 2011
Posts: 8
@JJ
it's because you can't override static final methods .
Suhrid Karthik
Ranch Hand

Joined: Aug 31, 2008
Posts: 58

Jeet Jain wrote:

I dont understand why "static final" prevent compilation?


Forget about the final keyword for the moment. An instance method cannot "override" a static method. Similarly a static method cannot "hide" instance methods - only static methods.
Now assuming growFast() was static in Thistle, then the final keyword will come into play - it prevents the subclass static method from "hiding" the superclass static method.
Jeet Jain
Ranch Hand

Joined: Sep 01, 2011
Posts: 53
thank you got it
 
Don't get me started about those stupid light bulbs.
 
subject: Overriding