File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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.
I agree. Here's the link:
subject: Overriding static methods?
It's not a secret anymore!