This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static methods are inherited but not overriden Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static methods are inherited but not overriden" Watch "Static methods are inherited but not overriden" New topic
Author

Static methods are inherited but not overriden

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
1. Static methods are inherited but not overridden (though can be redefined in the sub-class)

2. Only methods that are inherited can be overridden. As private methods are not inherited, they are not overridden. Static methods are inherited but not overridden. Constructors are not methods, hence can neither be inherited nor overridden..

Any reason why static methods are not overridden though they are inherited ?
Cor Takken
Ranch Hand

Joined: May 21, 2007
Posts: 58
Static methods are not inherited as normal methods are. The static methods are part of the class and are therefor part of every (sub)class. If a (sub)class however decides to re-define that method that method is re-defined. There are however a number of tricky rules which come into play when this happens.. Study the books on this.


SCJP 1.5
Dolphins are grey, but they dream in colour.
Armel Moukoss
Greenhorn

Joined: Mar 28, 2007
Posts: 14
Hi everyone,
I don't understand why this code produce this result : d a .
I think, il would be : d d. Thank you for your help.

Armel

Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
Originally posted by Armel Moukoss:
Hi everyone,
I don't understand why this code produce this result : d a .
I think, il would be : d d. Thank you for your help.


That's a really sneaky question. dostuff() and doStuff() are different method names!


SCJP 5.0
deepesh mathur
Ranch Hand

Joined: Aug 13, 2007
Posts: 39
Kelvin Lim
man you are really rocking..
i was wondering
how many tears(or i must say decades )of experience do you have in java??
hhow do you do this?
even such a small piece of mistake you can trace...
that's really awesome man..
hats off to you sir..
Abhijit Das
Ranch Hand

Joined: Sep 25, 2007
Posts: 156
Originally posted by Armel Moukoss:
Hi everyone,
I don't understand why this code produce this result : d a .
I think, il would be : d d. Thank you for your help.

Armel




Hello
Check the methods name ......
so, it is an independent method in Test

thanks
Abhijit


Abhijit Das
SCJP 5.0 | SCWCD 1.5
 
 
subject: Static methods are inherited but not overriden
 
Similar Threads
fun with main() and abstract
output of this code..
Static and Inheritance
Can static method be overridden?
Whats the Difference