This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

override

 
eswar kumar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why cant we override static methods?
 
Chandra Sekhar
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can only hide static methods,but not override them.A sub class cannot override a "class" method.A sub class can hide a static method in super class by declaring a static method in the subclass with the same signature as the static mathod in the super class.
At compilation time, the compiler matches the static method to the class referenced at compile time. It does not match it to the class used at runtime.
Chandrasekhar S.
SCJP
[ November 28, 2003: Message edited by: Chandrasekhar S ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic