Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Innerclass Qn 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 "Innerclass Qn" Watch "Innerclass Qn" New topic

Innerclass Qn

Ranch Hand

Joined: Apr 20, 2000
Posts: 50
This one is from JTest
Which statement is true about a non-static inner class?
A. It must implement an interface.
B. It is accessible from any other class.
C. It can only be instantiated in the enclosing class.
D. It must be final if it is declared in a method scope.
E. It can access private instance variables in the
enclosing object.
Ans given is E.
My ans B,D,E
I think B is partially true.
inner class can be accessed from outer class if it is not declared private.(and ofcourse we have to create the instance of enclosing class).
c)inner class inside method scope is implicitly final
We cannot subclass an inner class declared inside a method scope.
Please correct me if I am wrong.
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Innerclasses declard with in the method scope can be
declared abstract or final. When I heard this, even
I got .
I really don't know how this feature can be used,
but it helps to remember this for the exam
Hope this helps.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Ajay Kumar
Ranch Hand

Joined: Apr 28, 2000
Posts: 87
I found one of the most interesting inner class discussion on this forum.
Check this out
Hope this helps

Regds<BR>Ajay Kumar
Herbert Maosa
Ranch Hand

Joined: May 03, 2000
Posts: 289
B is obviously wrong. You should pay attention the phrase "any class". Surely an inner class is not accessed from any class, its accessibility outside the class in which it is defined will depend upon the its access modifiers and those of its encompassing class. And for a local inner class (one declared inside a method), you should know that it can never be declared as private,static,public or protected.And being local, you know that it exists only for as long as the method that contains exists. So it can only be accessed in the class that it is contained.
D is also wrong. You are right to say that local inner classes are implicitly final. Again pay attention to the phrase "must ". It is not a must that they be declared final, but they may be declared final, redundant though.
I think such phrases are what we ought to watch out for when deciding which answer is correct.

What do you think?
Ranch Hand

Joined: Apr 20, 2000
Posts: 50
I think I have to study little bit of English Grammer also for the Sun Certification Exam.

I agree. Here's the link:
subject: Innerclass Qn
It's not a secret anymore!