• 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 variable

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to know If variable A is Protected of class ABC of package 1 then can other class of same package 1 and also classes of package 2 access protected variable A?
thanks in advance for help!
ADS
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what I know
All the subclasses of Package A and Package B or any ither package(provided they extend this class) can access the protected variable.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi ADS,
The scope of the protected variable is for

all classes within the package and all subclasses

( it does not matter in which package subclasses are located )in which protected var is defined.It means protected var is available for all subclasses and for all other classes in the same package. Hope this clears yor doubt!!!

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Jaypii & Sunita,
Thanks for ur response.
What I understood that no matter what package, protected variables are accessed by all classes and sub classes of any package who extend the class of protected variable.
May I right?
Please confirm my clarification
Thanks a bunch!
ADS

Originally posted by ADS:
I would like to know If variable A is Protected of class ABC of package 1 then can other class of same package 1 and also classes of package 2 access protected variable A?
thanks in advance for help!
ADS


 
Sunita Vontel
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes u r right.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI SUNITA,
THANKS A LOT!
ADS

Originally posted by ADS:
HI Jaypii & Sunita,
Thanks for ur response.
What I understood that no matter what package, protected variables are accessed by all classes and sub classes of any package who extend the class of protected variable.
May I right?
Please confirm my clarification
Thanks a bunch!
ADS


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic