This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Default Access for Classes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Default Access for Classes." Watch "Default Access for Classes." New topic
Author

Default Access for Classes.

Brit Wright
Greenhorn

Joined: Aug 16, 2003
Posts: 3
Hello All:
If there are two classes, say, C1 and C2, and both belong to default package, i.e, none of them are set to be in any specific package, can they access each others public, default, and protected members?
Class C1{
public f1(){ };
protected f2(){ };
}

Class C2{
public f3 () {};
protected f4 () {};
}
I am new to java. So, please, just mentor me even if you find my question bit silly...
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Howdy
No, the question isn't silly. And you're absolutely right, even in the default package, if two classes are in the default package they can both access each other's public, default, and protected members.
cheers,
Kathy
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Default Access for Classes.
 
Similar Threads
protected member class
Why recompile?
access problems
protected and default constructor
inhertitance through multiple packages - not able to analyze the output-