wood burning stoves 2.0
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: 9059
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.

I agree. Here's the link: http://aspose.com/file-tools
subject: Static Methods
It's not a secret anymore!