This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding static methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overriding static methods?" Watch "Overriding static methods?" New topic

Overriding static methods?

Ramana Uppala

Joined: Jan 04, 2005
Posts: 16
Hi I read some where that we can't override the static methods.
But this program works fine.
Can any one explain abt static methods override?

( tags added)
[ February 25, 2005: Message edited by: Barry Gaunt ]
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228

A subclass cannot override methods that are declared static in the superclass. A subclass can hide a static method in the superclass by declaring a static method in the subclass with the same signature as the static method in the superclass.
[ February 25, 2005: Message edited by: Srinivasa Raghavan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Animesh Shrivastava
Ranch Hand

Joined: Jul 19, 2004
Posts: 298
By the code what u have written u may not be able to conclude that ur static methods are overridden or not.
Try this way:

After running,
U can see that the method being called is not of Object check1, but of check2
But if the methods are not static,u get a different behaviour

Hope u understand.
Ramana Uppala

Joined: Jan 04, 2005
Posts: 16
I got the point.
Have you checked out Aspose?
subject: Overriding static methods?
It's not a secret anymore!