aspose file tools*
The moose likes Beginning Java and the fly likes Static methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static methods" Watch "Static methods" New topic
Author

Static methods

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Is it legal to override a static method?
-Dale

------------------
By failing to prepare, you are preparing to fail.
Benjamin Franklin (1706 - 1790)


By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
Even though you can have the same static method in the subclass as the super class, it's not actually overidding. i.e. you can not call super.superclassmethod() from the subclass.

Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Dale
Static methods aren't overridden they're hidden. If you have a static method with the same signature in a subclass as there is in the super class the subclass method will hide the superclass method. In other words static methods behave like variables and are subject to early binding not runtime.
Check out this code:

The output is:
super class method
sub class method
super class method
You can see that the last method call, if the method were overridden, would have called the subclass method.
hope that helps


------------------
Dave
Sun Certified Programmer for the Java� 2 Platform


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static methods
 
Similar Threads
static and non static methods
static and non static methods
Single tone Vs Static
WA #1.....word association
property file dynamic vs static