wood burning stoves*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Overriding of Static Method" Watch "Overriding of Static Method" New topic
Author

Overriding of Static Method

Faraz Alig
Greenhorn

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: 1659
    
  11

Have you tried? What happens?


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

Joined: Sep 28, 2004
Posts: 18507
    
  40


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?

Henry


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

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


SCJP 1.5
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Overriding of Static Method
 
Similar Threads
tere is a ques abt static method.
Float wrapper takes double primitive implicitly.
About overriding
can a static method be override.
Question