File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inner class 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 "Inner class" Watch "Inner class" New topic

Inner class

satishind Reddy
Ranch Hand

Joined: Oct 17, 2000
Posts: 33
I have seen below statement in one mock exame answer reasoning.
"Locale inner classes may not be declared public, protected, private."
"Locale Inner classes are not associated with an instance of an outer(enclosing) class."
i think this statements is wrong. Becaus we can declare inner classes public,protected,private, and static.
Please correct me if i am wrong.
can any one tell the difference between inner classes and Locale inner classes.
Thanks in advance....
Milind Mahajan
Ranch Hand

Joined: Oct 23, 2000
Posts: 77
Both statements are right. A local inner class is one which is defined inside a method. A non-local inner class (or simlpy inner class) is one which is a member of a class.
A local inner class's scope is only inside the method containing it. So you can instantiate that class only inside that method. So, there is no question of local inner class being associated with the instance of the outer class.
It cannot be static, private, protected etc. I think it is because any member (for eg. variables) of method cannot static, private, protected etc. But it can be final ; so can the variables inside methods.
Hope this helps. Please correct me if I am wrong.
I agree. Here's the link:
subject: Inner class
jQuery in Action, 3rd edition