aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Public Member Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Public Member Access" Watch "Public Member Access" New topic
Author

Public Member Access

leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
Hi everyone,
I'm having trouble understanding something, and I think an assumption is being made that I'm not aware of.
In Kathy and Bert's SCJP2 cert book on page 73 there is a class called Toon which invokes the doRooThings method on a Cloo instance.
However, should i assume that the Toon class is in the same package as Cloo? The text doesn't specify a package name for the Toon class. Here is the code:

I thought that since the Roo class is not marked public that only classes in the same package can access members of this class.
There isn't a package declaration for class Toon. Is it in the same package as Cloo? I know it looks like it is here in this example, but the book is unclear whether it is or isn't.
Also, since class Toon doesn't extend Cloo, then I'm invoking the method doRooThings in class Toon from the Cloo class, right?
[ May 21, 2003: Message edited by: leo donahue ]

Thanks, leo
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Howdy -- you are absolutely right -- in order for this code to work, class Toon must have been declared in the same package as Cloo, since Cloo is not public.
We didn't specify it either way because, well, because I have no idea why. We should have made it explicit! But you figured out what must be true in order for that to work. We were concentrating on the actual doRooThings() method rather than the class itself.
Sorry, and thanks for the catch
cheers,
Kathy
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
Kathy,
Thanks for your response. Nothing to be sorry about. I just wanted to be sure I was following your example correctly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Public Member Access