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, 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>