• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

static mathods/variable inheritance

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are static methods/variables inherited?
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it depends on their access modifiers.
The access modifiers are:
Public, private, default and protected
In case the access modifier is "public", the static method/variable is visible in same class, same package subclass,same package non-subclass,different package subclass and different package non sub class.
In case when it is "private", its visible and hence inherited only by the members of the same class.
In case of "default" i.e.when no access modifier is specified,they are visible in same class, same package subclass and same package non-subclass.But not in diff package sub class and diff package non subclass.
When the method/variable has "protected accessibility, then it is accessible/inherited by same class, same package subclass, same package non subclass and different package subclass but not in different package non subclass.
Thus,depending on accessibility modifiers of the static members in a class, clients can access them.
Hope this will help me.
Please correct me if I am wrong anywhere.
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic