• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need clearification

 
Muhammad Saghir
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
thanks
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saghir,
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 ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic