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.
No, default access is not more than protected access. You can remember this using the following: protected access = (default access, i.e access within same package) + (access to subclasses in other packages)
Joined: Jun 30, 2000
I think protected methods are only accessible to its subclasses, but default methods are accessible any where within the same package. But you are also right.
Hi Rakesh, first of all i would like to tell u that u have indeed raised very good question. It really boggled me. u r logic is correct. the access specifiers based on accessibility IMO are public protected default private however a top level class can only be of default or public class. I checked out the JLS version 2 8.1.1 on this. I quote "Not all modifiers are applicable to all kinds of class declarations. The access modifier public pertains only to top level classes and to member classes. The access modifiers protected and private pertain only to member classes within a directly enclos-ing class declaration. here is section 7.6 which clearly states "It is a compile time error if a top level type declaration contains any one of the following access modifiers: protected, private or static." so as per the JLS the matter stands closed but as to why? the question is still open. Regds. Rahul.
Joined: Nov 22, 2008
What would <code>protected</code> mean when applied to a top-level class? <code>protected</code> members are accessible to subclasses and other classes in the same package and <code>public</code> members are accessible anywhere the class is accessible, so there is a clear progression of access modifiers with respect to members. <code>public</code>, when applied to a class, means the class is accessible anywhere its package is accessible. Drawing a parallel with the case of <code>protected</code> members, the only meaning I can see of a <code>protected</code> class would be that the class is accessible to "subpackages" (derived from the class's package), but there is no such thing as inheritance of packages. Containment isn't inheritance. Note that inner classes can be <code>protected</code> because they are members and so are subject to inheritance (controlled by their access modifier) when their enclosing class is extended.
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