Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Public variable

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If variable a of class ABC in package 1 is Public but class ABC is private.
Can other class from other package 2 or same package 1 access variable a of class ABC in package 1 ?
Thanks in advance,
ADS
 
N Mukherjee
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
No..it's not accessible.If the class is private..it becomes the
deciding factor no matter what the access specifier your variable
is having.
It all depends on the class(first) and then variable(Second).
As the cl;ass is private it is not accessible from any package or any class
outside this package where the top class is.
Hope this helps.
NM
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI N Mukherjee
Thanks a bunch!
Now I understood.
Also I would like to know then what about Protected means If it variable 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?
Thanks again
ADS
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic