×

Loading...

Jabber's comments

jabber (jabber)
The answer will be 15.

This quiz tests our understanding of accessibilities for Java instance variables.

"x" is private so we cannot directly access it
by saying a.x in another class, where a is
an instance name. In the example code,
teh author used ref.x, but this piece of code is still in the definition of AClass. So the author DID NOT violate the accessibility of private variables. Hence, there won't be compiling-time error, let alone the run-time problem.

In summary, private means one cannot access a variable from out of the class definition. Say again, in the example code,
the auther used "a.x" syntax in the definition of the class AClass.

Hope it helps
(#10399@0)
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技术讨论