This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi Anil Well I guess thats it's not really neccessary to make a data member private for encapsulation. Default access and protected modifier should also do the work. It depends on how tightly encapsulated you want the data in your code to be.
Even where you only have package access, it still seems to me that you'd want tight encapsulation. Think of it from a user's point of view: what a pain it would be to have to wade through all the methods and fields to figure out what to do. It's much better to make the relevant methods and fields private, thus enabling the user to focus on what is important, ie what is accessible. [ May 26, 2003: Message edited by: Roger Chung-Wee ]