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

回到话题: Java Quiz

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论