This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

scope

 
sun par
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sun par
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic