Hiall, I've red the following on a study note by "Ashraf Fouad Ayoub". In a true false question. could you explain me the following sentence: Objects themselves do not have visibility, only references to the object In what context? What do you think it refer to?
It means that when declaring private Object obj = new Object(); as an instance member of some class, it is the reference variable obj that is private to the class in which it is declared, not the actual Object instance refered to by obj (which is on the heap). The object instance could be returned by some method in the class but the reference variable itself cannot.
No! An object cannot be private or protected or whatever access you may want to give it. Only the reference to an object, that is the variable you are using for referencing the object, may have an access modifier.
An object although private can be updated having copy of its reference?
Once you have a reference to this object you want to update it right. In order to update it you must call or access its members. This is when the access modifiers come into play again since you won't be able to call or access members of that object that have restricted access (private, default and you are in another package, protected and you are in another package and not a subclass).