Originally posted by James Tharakan:
I guess the below fragment of code would justify why option b is not correct.
Even though varibles are private.A sub class can change the values of varibles.(without the aid of particular class object)
new subClass().setValue(5,6);
Hope i put my point corretly.
[ December 23, 2008: Message edited by: James Tharakan ]
Actually, the code above is tightly encapsulated. The whole point of encapsulation is to have private instance variables and to offer a public interface to change those variables. That way you can make sure that the state of the object doesn't become inconsistent (you could enforce any rules in setValue() above to make sure of that.)
I don't understand what you mean by "A sub class can change the values of varibles." The method is public, so a class doesn't need to be a subclass to change the private instance variables of A.