wood burning stoves*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overriding static methods?" Watch "Overriding static methods?" New topic
Author

Overriding static methods?

Ramana Uppala
Greenhorn

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
Ramana,

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
Ramanna,
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
Greenhorn

Joined: Jan 04, 2005
Posts: 16
Thanks,
I got the point.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding static methods?
 
Similar Threads
Check/Uncheck check boxes when All check box is enabled/disabled...
Method Overriding
Java Class loading
Legal Arguments for If Statements
Running a Java Program