• Post Reply Bookmark Topic Watch Topic
  • New Topic

Usage of private access modifier  RSS feed

 
chamini prashakthi
Ranch Hand
Posts: 127
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
according to the following source code sum and NUMBER variables are declared as private.According to my knowledge private variables can only use within class.But following program doesn't give any error.Can some one explain the reason for this .






 
Stephan van Hulst
Saloon Keeper
Posts: 7974
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't actually show us code where sum and NUMBER are being accessed outside of their declaring class' file.
 
chamini prashakthi
Ranch Hand
Posts: 127
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from call to this add method.so, add method use those sum and NUMBER parameters. Isn't it?
 
Tim Moores
Saloon Keeper
Posts: 4024
94
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that counts as use inside of the class in which they're declared.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!