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 Need clearification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Need clearification" Watch "Need clearification" New topic

Need clearification

Muhammad Saghir

Joined: Mar 06, 2002
Posts: 6
Hello All
I have one confusion while i was doing Mercus Green Mock Exam #3.In question no.17 and 48 he says that "static methods may not/ cannot be overridden to be non-static" and in one of the answers it is correct.
But in kahlid azim mughal's book he says "private ,static and final methods cannot be overriden".
can someone clearify this point.

Saghir SCJP2
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
Welcome to Javaranch
Static method cannot be overridden because static methods are not inherited. Static methods can be hidden, though, which means that you may have two static methods with the same signature in the superclass and in the subclass.
Moreover, it is illegal (as per JLS 8.4.6 Inheritance, Overriding, and Hiding ) to hide a static method with a non-static method. Also, it is illegal to override a non-static method with a static method.
Please, read the Javaranch Naming Policy and change your publicly displayed name to comply with our unique rule. Thank you for your cooperation.
[ March 06, 2002: Message edited by: Valentin Crettaz ]

[Blog] [Blogroll] [My Reviews] My Linked In
I agree. Here's the link:
subject: Need clearification
It's not a secret anymore!