This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Please verify this statement from K&B book Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Please verify this statement from K&B book" Watch "Please verify this statement from K&B book" New topic
Author

Please verify this statement from K&B book

Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 164
Once the subclass-outside-the-package inherits the protected member,
that member (as inherited by the subclass) becomes private to any code outside
the subclass, with the exception of subclasses of the subclass.

But i see that even the subclasses of the subclass cannot access the protected member being accessed by child.

Please provide me an example?
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 536
Well protected members can be accessed using the subclass type but if that subclass is extends by a subsubclass, then that protected variable which was there in the parent class cannot be accessed by that subsubclass type because it is not inherited at all...i hope its clear

cheers


[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Harsh Pensi
Ranch Hand

Joined: Aug 05, 2009
Posts: 67
But i see that even the subclasses of the subclass cannot access the protected member being accessed by child.


This member cannot be accessed directly i.e. by using a reference of the class that defines it or the subclass. But it can be accessed in subclasses of the subclass only through inheritance.


SCJP6 - 93% SCWCD5 - 97%
Valentin Ivanov
Ranch Hand

Joined: Nov 20, 2008
Posts: 36

Hi, Jacob Sonia

Would you take a look at this
I think it explains all you are asking for.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Please verify this statement from K&B book
 
Similar Threads
Access Specifier
subclass outside package
Possible error in K&B book (resolved - no error)
confusion regarding protected keyword
question about protected modifier