Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why is this wrong?  RSS feed

 
Tony Sam
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Static methods can be overridden by static methods only. " is Wrong, why is "Static methods cannt be overridden by non-static methods" correct ?
i dont understand it, hope someone helps!!
 
R K Singh
Ranch Hand
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tony Sam:

why is "Static methods cannt be overridden by non-static methods" correct ?
Because compiler won't allow you.
"Static methods can be overridden by static methods only. " is Wrong.
Because static methods are hidden not overridden.
HTH
CMIW

------------------
Regards
Ravish
 
amit mawkin
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with ravish static methods are hidden and are not overridden in subclasses
------------------
coffee drinker
-----------------------
Sun Certified Programmer for Java 2 Platform
 
Jim Hall
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question was just posted yesterday.
http://www.javaranch.com/ubb/Forum24/HTML/013653.html
 
Tony Sam
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ravish kumar:
[b]why is "Static methods cannt be overridden by non-static methods" correct ?
Because compiler won't allow you.
"Static methods can be overridden by static methods only. " is Wrong.
Because static methods are hidden not overridden.
HTH
CMIW
[/B]

i know ,just one word : "Static method are not overridden." ,
is this OK?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is, but they are hidden instead
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Andre Zhang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Valentin Crettaz:
yes it is, but they are hidden instead

does HIDDEN mean that the static method cant be accessed by the subclass?
 
Karen Leoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following statements are true.. but I hope someone can elaborate on them..
Static methods are never overridden. They are hidden or shadowed just like fields.
Static methods cannot be shadowed by a non-static method and vice versa.
Static method can be shadowed by a static method in the subclass.
Can anyone one please elaborate what does hidden or shadowed means? What's the difference between the two?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!