This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Protected Keywords - More Info about it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Protected Keywords - More Info about it" Watch "Protected Keywords - More Info about it" New topic
Author

Protected Keywords - More Info about it

Nelly Verccety
Greenhorn

Joined: Feb 16, 2006
Posts: 8
I am analyzing java code using QJ-Pro and it comes with the next message:
Do not define protected members in classes that are not part of a named package. Anyone know what that means?

The line that is refering too is the following:
protected Panel getPanel() {return this;}

What do I need to know about protected keyword before I use it?
Nelly Verccety
Greenhorn

Joined: Feb 16, 2006
Posts: 8
Other thing, when is protected best used and where should be placed it so that its clear and will not break encapsulation?
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
Protected members are accessible in the same class or its subclasses.
If accessed from subclass , the instance should be of the class from where the protected member is being accessed or its subclass. The package may differ in this case.


SCJP 1.4 85%
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Protected Keywords - More Info about it
 
It's not a secret anymore!