This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static mathods/variable inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static mathods/variable inheritance" Watch "static mathods/variable inheritance" New topic

static mathods/variable inheritance

geeta rai
Ranch Hand

Joined: Sep 18, 2003
Posts: 48
Are static methods/variables inherited?
mrudul joshi
Ranch Hand

Joined: Nov 12, 2003
Posts: 54
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.
wood burning stoves
subject: static mathods/variable inheritance