Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static mathods/variable inheritance

 
geeta rai
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are static methods/variables inherited?
 
mrudul joshi
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic