• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Java OCA 8 Programmer I Study Guide (Sybex Ch 4 - p179)  RSS feed

 
Greenhorn
Posts: 2
Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Topic Protected Access

Can you please explain "member reference to the same class or a subclass" in the following context?

A member is used through a variable. This is the case on lines 10, 11, 15, and 16.
In this case, the rules for the reference type of the variable are what matter. If it is a
subclass, protected access is allowed. This works for references to the same class or a
subclass.

There is an example on pg 178

 
Marshal
Posts: 63447
206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell us which book that is, including authors, and whether you are quoting the book exactly.
 
author & internet detective
Posts: 39159
724
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's my book (Sybex.)

The key point of that example is that you can call the same method and it can work/not work depending on how it is called. Noticed how the variable used is from one class or another in each case
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a doubt exactly about this point,

I try this code on my JDK and it is ok
it compiles normally...

Capture-d-e-cran-2019-02-25-a-11.27.23.png
[Thumbnail for Capture-d-e-cran-2019-02-25-a-11.27.23.png]
 
Campbell Ritchie
Marshal
Posts: 63447
206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

What you posted is different code because you haven't declared any package names.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!