• Post Reply Bookmark Topic Watch Topic
  • New Topic

Overriding rules  RSS feed

 
Tina Low
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, while studying overriding stuff I was a little confused, because literature is contradictory.
Can anybody help me through?
Can I override methods:
static - to be nonstatic
static - to be static
nonstatic - to be nonstatic
(I think yes)
non static - to be static
Any suggestion where this make sense in programs?
Thanks Tina
 
girish rateshwar
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tina,
Static method cannot be overridden( to non static).
But i guess u can hide a static method inside a sub class i.e you can declare a static method in the subclass with the same signature as a static method in the superclass.
[ December 16, 2002: Message edited by: girish rateshwar ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the JavaRanch Newletter there is an article called The Games Objects Play which has a section on Hide and Seek. That lists all the combinations of methods trying hiding and overriding and what happens if you try to do them.
Have Fun!!
 
Tina Low
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the help.
The games play (hiding/Overriding) was pretty good. It helped me to pass the SCJP2 Exam
on 10.1.03.
Thanks a lot Tina :roll:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!