wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Examulator doubt on inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Examulator doubt on inner classes" Watch "Examulator doubt on inner classes" New topic
Author

Examulator doubt on inner classes

Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
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.


all events occur in real time
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
Could you post some code that illustrates this?


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Sure, here's an example


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

Yours,
Bu.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Examulator doubt on inner classes
 
Similar Threads
String Question - Im in Doubt
When is an anonymous inner class NOT an inner class? Always?
Method-Local Static Inner Class
Inner classes
Encapsulation question