Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Examulator doubt on inner classes

 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

I know, Marcus Green has an own discussion group about his questions.
But today Christie Thom posted here

that she passed the exam.
Congratulations!


And further:
Actually I am surprised that I got lot of questions from inner classes I can't remember exactly but almost 10 questions.

So I post this inner class question here.
In the question of today (question #99)
http://www.examulator.com/phezam/question.php

about method local inner classes the question was:
Which of the following statements are true of a method local inner class?


the correct answer given was
1) It has access to all members of its enclosing class
2) It can only access final variables of its enclosing method

I think that answer 1 is false. If the method (where the inner class is in) is static, the inner class has no access to non-static members of the enclosing class. So we can't say it has access to all members.

Any comments // on that?



Yours,
Bu.
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post some code that illustrates this?
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, here's an example


The error is the classic one: "Cannot make a static reference ...".

Yours,
Bu.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic