• Post Reply Bookmark Topic Watch Topic
  • New Topic

wrong answer???  RSS feed

 
O Joseph
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
------------------------------------------------------------------------
7. Which of the following statements are true?
[a] An inner class may be declared as private
[b] An inner class may be declared as static
[c] An inner class can declared inside a method
[d] An inner class can access all the variable in the enclosing method.

answers:a,b,c. I thought d would have been included since it aint talking about all top level nested class - so why not?
------------------------------------------------------------------------
 
Vicken Karaoghlanian
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
inner classes that are declared in a method can only access global variables, or the local variables that are declared final.
 
Steve Lovelace
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice the phrase "in the enclosing method". This question is about a local class. It cannot access all the variables in its method - only the final ones.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!