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 Static Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static Methods" Watch "Static Methods" New topic

Static Methods

Senthil Nathan

Joined: Jul 23, 2005
Posts: 2
what happens if i extend a class to subclass and try to override the static method in superclass using following objects

1) subclass obj=new subclass()

2) superclass obj=new superclass()

3) superclass obj=new subclass()

what be internally happen which would be inherited anr override and which willl not override.
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9044
Hi, Notmine Jeoffrey

Welcome to JavaRanch! Please adjust your display name to meet the JavaRanch Naming Policy.
You can change it here.


Now, on to your question: You can try to override the static method in superclass, but it is impossible.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200

If you want to override the static method in the super class, it will be called as Overhidding and not Overriding.

I given the sample program below. Just go thru it.

Note: I am also in learning curve. If anything wrong in this, pls post the reply.

jQuery in Action, 2nd edition
subject: Static Methods