Let me try it.

sailor (Sailor)
A compiler error will be generated.

In the method "add" in class "AClass", the variable "ref" refers to another object rather than the object who executes this method. Thus a call to "ref.x" is invalid, because x is a private member.

I admit this program is quite tricky, and it's helpful for us new learner.

Thanks peterlf.
2000-10-10 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: Java Quiz

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论