Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request to Barry Gaunt and Bert Bates

 
Sac Anand
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Barry / Bert

Request you to please look at the below mentioned thread:

Doubt in K&B SCJP 5: protected access

As mentioned in the aforementioned thread initiated by Peter Schubert, i strongly support Peter.

K&B - page 36 says
The bottom line: when a subclass-outside-the-package inherits a protected member, the member is essentially private inside the subclass, such that only the subclass and its subclasses can access it.


An exception to the bold portion above is, any class, in the same package of Parent class, can access the inherited protected variable of subclass-outside-the-package without using inheritance.

To support the above statement, Peter has given an excellent example in the abobe mentioned thread.

Best Regards,
Sachin Anand
 
Alangudi Balaji Navaneethan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What they have written is correct. It should be understood that inside the package where the subclass is, only the subclass and the subclasses of it are able to access the protected member which has been declared in any outer subclass as protected...
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Kathy here, answering the question under Bert's log-in]

I agree with Peter. Sachin, thanks for bringing this up again... I responded in the original thread, but in a nutshell--Peter's correction (and suggestion for improving the wording) is absolutely right!

Cheers,
Kathy
 
Sac Anand
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Kathy

Regards,
Sachin Anand
 
Alangudi Balaji Navaneethan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kethy,

If so what Have I said is correct?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic