aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Access Modifier Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Access Modifier Doubt" Watch "Access Modifier Doubt" New topic
Author

Access Modifier Doubt

Sachin N Naik
Greenhorn

Joined: Jun 09, 2006
Posts: 11
Hello Friends,

I'm studying K & B book for SCJP 1.4. I have a doubt regarding Access Modifiers in Java. In K & B book a Table 2.1 is given on page 83.
In this table second row says that "You can access a protected member of a from any class in same package". Can you please explain the meaning of this.
I think this doesnt work because you need to extend that class even if its in the same package.

Thanks,
Sachin Naik
Lukas Stephienn
Ranch Hand

Joined: Dec 23, 2005
Posts: 60
No, protected in java works diffrently from c++.
K&B are correct.
Protected can be accesses within a package or from subclasses (but only through inheritance).


SCJP 5.0 (91%), SCBCD 1.3 (94%), SCWCD 1.4 (88%)
Sachin N Naik
Greenhorn

Joined: Jun 09, 2006
Posts: 11
Thanks Lucius, you are right. Actually i was under impression that book is saying that protected members can be accessed without inheritance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Modifier Doubt
 
Similar Threads
Doubt in overriding
doubt
Doubt
Doubt
Package Doubt :(