Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile 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.
Have you tried LearnNowOnline?
subject: static mathods/variable inheritance