• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Static methods - final

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

I read that


static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object.



I cannot make a sense of this. I want to try some code which explains this. Any help ?

* implicitly final ?
* overriding is done based on the type of the object ?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it's not true. Static methods aren't implicitly final. Where did you read this? I suggest you simply disregard this statement, as it will just lead to confusion.

It's possible (mmmm, probable) that the author was trying to say that static methods can't be overridden. This is true, but it's not the same as being final. See here for more about "overriding" static methods if you want to learn more.
 
Arnb Sen
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jim. I will ignore that statement.

How about the next one ? "overriding is done based on the type of the object ?" - what does this mean ? If this is not correct either - I better give up the article that I am reading on the net
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think "attached to the object" means that different objects are formed from different classes, and object A might be from a subclass of the class object B is from, so the two objects have different methods.
I think your suggestion of reading something else might be a good one
CR
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic