Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding static methods?

 
Ramana Uppala
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I read some where that we can't override the static methods.
But this program works fine.
Can any one explain abt static methods override?



( tags added)
[ February 25, 2005: Message edited by: Barry Gaunt ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramana,

A subclass cannot override methods that are declared static in the superclass. A subclass can hide a static method in the superclass by declaring a static method in the subclass with the same signature as the static method in the superclass.
[ February 25, 2005: Message edited by: Srinivasa Raghavan ]
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramanna,
By the code what u have written u may not be able to conclude that ur static methods are overridden or not.
Try this way:


After running,
U can see that the method being called is not of Object check1, but of check2
But if the methods are not static,u get a different behaviour

Hope u understand.
 
Ramana Uppala
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
I got the point.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic