• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static Methods

 
Senthil Nathan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happens if i extend a class to subclass and try to override the static method in superclass using following objects

1) subclass obj=new subclass()

2) superclass obj=new superclass()

3) superclass obj=new subclass()

what be internally happen which would be inherited anr override and which willl not override.
 
Marilyn de Queiroz
Sheriff
Posts: 9061
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Notmine Jeoffrey

Welcome to JavaRanch! Please adjust your display name to meet the JavaRanch Naming Policy.
You can change it here.

Thanks!

Now, on to your question: You can try to override the static method in superclass, but it is impossible.
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If you want to override the static method in the super class, it will be called as Overhidding and not Overriding.

I given the sample program below. Just go thru it.

Note: I am also in learning curve. If anything wrong in this, pls post the reply.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic