A class can not be called "tightly encapsulated" unless which of the following is true?
a. The class is declared final.
b. All local variables are declared private.
c. All method parameters are declared final.
d. No method returns a reference to any object that is referenced by an internal data member.
e. None of the above
Answer : E. THe explanation is "However, the methods of a tightly encapsulated class may return a reference to an immutable object or a reference to a copy or clone of an internal object.". I don't quite understand to this sentence. What is "a reference to a copy or clone of an internal object"? And reference to an immutable object, does it mean to a String object?
Thanks
David
a. The class is declared final.
b. All local variables are declared private.
c. All method parameters are declared final.
d. No method returns a reference to any object that is referenced by an internal data member.
e. None of the above
Answer : E. THe explanation is "However, the methods of a tightly encapsulated class may return a reference to an immutable object or a reference to a copy or clone of an internal object.". I don't quite understand to this sentence. What is "a reference to a copy or clone of an internal object"? And reference to an immutable object, does it mean to a String object?
Thanks
David