• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Protected?

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
When method or variable is declared Protected can be accessed from subclass or supercalss?
Thanks
[ June 03, 2002: Message edited by: Dirk Schreckmann ]
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A protected variable or method is visible to all classes in the SAME package.
Regards,
Reuben.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not quite. When a class element is explicitly declared protected it is available to the declaring class and any classes that extend that class.
If no access modified is specified (termed "default access" or sometimes "package protected"), then the element is available to all classes in the same package as the declaring class.
hth,
bear
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Not quite. When a class element is explicitly declared protected it is available to the declaring class and any classes that extend that class.


and all classes in the same package as the declaring class. The java access modifiers are strongly hierarchical (at least since 1.1, when they dropped "private protected" :roll: ).
 
reply
    Bookmark Topic Watch Topic
  • New Topic