• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Static methods are inherited but not overriden

 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Static methods are inherited but not overridden (though can be redefined in the sub-class)

2. Only methods that are inherited can be overridden. As private methods are not inherited, they are not overridden. Static methods are inherited but not overridden. Constructors are not methods, hence can neither be inherited nor overridden..

Any reason why static methods are not overridden though they are inherited ?
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Static methods are not inherited as normal methods are. The static methods are part of the class and are therefor part of every (sub)class. If a (sub)class however decides to re-define that method that method is re-defined. There are however a number of tricky rules which come into play when this happens.. Study the books on this.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I don't understand why this code produce this result : d a .
I think, il would be : d d. Thank you for your help.

Armel

 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Armel Moukoss:
Hi everyone,
I don't understand why this code produce this result : d a .
I think, il would be : d d. Thank you for your help.



That's a really sneaky question. dostuff() and doStuff() are different method names!
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kelvin Lim
man you are really rocking..
i was wondering
how many tears(or i must say decades )of experience do you have in java??
hhow do you do this?
even such a small piece of mistake you can trace...
that's really awesome man..
hats off to you sir..
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Armel Moukoss:
Hi everyone,
I don't understand why this code produce this result : d a .
I think, il would be : d d. Thank you for your help.

Armel




Hello
Check the methods name ......
so, it is an independent method in Test

thanks
Abhijit
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic