File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Overriding of Static Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Overriding of Static Method" Watch "Overriding of Static Method" New topic

Overriding of Static Method

Faraz Alig

Joined: Mar 14, 2010
Posts: 24
Is it possible to override the static method in subclass? If not then please explain why?

~ Faraz
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1789

Have you tried? What happens?

When you do things right, people won't be sure you've done anything at all.
Henry Wong

Joined: Sep 28, 2004
Posts: 20526

To be more specific, create a subclass object, cast it to its superclass type, and try to call the static method... which one gets call? the original super class one? or the subclass version?


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Schumi Mic

Joined: Apr 17, 2010
Posts: 4
@Faraz: You can find this in-detail @ Overriding Vs Hidding

SCJP 1.5
I agree. Here's the link:
subject: Overriding of Static Method
It's not a secret anymore!