wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "scope" Watch "scope" New topic
Author

scope

sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
What is the output of trying to compile and run the following code?
(Select one correct answer)
-----------------------------------------------------------------------

-----------------------------------------------------------------------
A: The code does not compile due to line //1.
B: The code does not compile due to line //2.
C: The code does not compile due to line //3.
D: The code compiles and runs with output 0.
E: The code compiles but has runtime exception
at line //3.



--------------------------------------------------
The answer given is D. I thought that since method is private its scope is inside the class Inner. That is it can be accessed only through other methods in the class. Can someone explain please?
Thanks.
[Dan added the UBB codes to format the code block.]
[ February 25, 2003: Message edited by: Dan Chisholm ]

Sunita<br />SCJP 1.4
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Sunita,
An enclosing class has access to the private members of a nested class. Similarly, the nested class has access to the private members of the enclosing class.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
Thanks Dan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: scope