pharaoh fortune slot
ExamNotes.net
Welcome, Guest. Please login or register.
November 19, 2017, 01:03:23 AM

Login with username, password and session length
* Home Help Search Login Register
+  ExamNotes.net
|-+  Other IT certifications
| |-+  Java certification exams
| | |-+  protected access
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: protected access  (Read 1960 times)
zoidberg
Junior Member

Offline Offline

Posts: 1

0


View Profile
« on: June 20, 2005, 06:00:41 PM »

I'm currently preparing for the SJCP 5.0 exam. I'm using a book called "Complete Java 2 Certification Study Guide" by Philip Heller and Simon Roberts.
In the chapter about access modifiers they repeatedly claim that an instance of a class that extends a class in a different package can access protected methods on itself but not on a different instance of the same class. This contradicts with my knowledge (and of course I verified with real code that this does work).
Am I getting something wrong? Access modifier violations are verified at compile time. The compiler cannot know on which instance the code runs, so it cannot enforce this access restriction.
Mistakes may happen, but since this claim shows up consistently at serveral places in the book, I'm a little confused.

Regards
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!