Posted By:
Qatz_Smith
Posted On:
Thursday, December 22, 2005 11:55 PM
For the last 6 years I've understood that the scope is the ability of accessing an object's member (attribute or method). But after seeing a example Java code and finding out that it compiled successflly... I've started to wonder that I was aways wrong. Not completely wrong, but still wrong. public class A { private int i; public copyValue( A a) { this.i = a.i; // accessing a's private attribute w/o an error } } Or is it that, the 'Scope' controls the accessibility of a class, and not the instance of a class. If the class that is calling the member and the class that is the owner of the member are the same class, then the caller can access all private members.
More>>
For the last 6 years I've understood that the scope is the ability of accessing an object's member (attribute or method). But after seeing a example Java code and finding out that it compiled successflly... I've started to wonder that I was aways wrong. Not completely wrong, but still wrong.
public class A
{
private int i;
public copyValue( A a)
{
this.i = a.i; // accessing a's private attribute w/o an error
}
}
Or is it that, the 'Scope' controls the accessibility of a class, and not the instance of a class. If the class that is calling the member and the class that is the owner of the member are the same class, then the caller can access all private members.
Can any one help me on the issue. Is there any sources of documents, theories, etc. that will support the issue.
<<Less