This content has been marked as final. Show 7 replies
When I tested using some code, I was able to accessAnd the subclass was in the same package as the superclass, right? If so, then the members were visible for that reason, not because they were part of a subclass.
s default members inside a subclass.
Visibility public protected default private From the same class yes yes yes yes From any class in the same package yes yes yes no From any class outside the package yes no no no From any subclass in the same package yes yes yes no From any subclass outside the package yes yes no no
Thanks Nasch! Right, right ,... the subclass was within the same package and I also agree that the members were visible because the subclass was within the same package which means that a default member is accessible from:
1) within the same class
2) within any other class in the same package
3) and finally from any subclass within the same package.
So if this is correct, as is the case according to the table that Grand_poobah has provided, then shouldn't there be an X mark in the Subclass Column of the Java Tutorial for the Package row???
Did I confuse you all? Sorry, didn't mean too.
Thanks Nasch and Grand_poobah for your considerations!
> then shouldn't there be an X mark in the Subclass Column of the Java Tutorial for the Package row???
Yes, with the proviso that the subclass is, in fact, in the same package.
Their table doesn't actually break that down.
Thank you Grand!!
Now try the default modifer for fields and members of an interface.
Note: they are not the same.
thanks I haven't leaned interfaces well and so I'll have to postpone it until I know what to do. But I'll keep that in mind!