pharaoh fortune slot
Welcome, Guest. Please login or register.
October 17, 2018, 01:58:22 PM

Login with username, password and session length
* Home Help Search Login Register
|-+  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 2117 times)
Junior Member

Offline Offline

Posts: 1


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.

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!