wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes problem from sun sample Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "problem from sun sample" Watch "problem from sun sample" New topic
Author

problem from sun sample

Basu Patel
Ranch Hand

Joined: May 28, 2000
Posts: 60
Given the following question, I am definate about option e as correct, but for non-static inner classes should'nt option c also hold correct considering (new outer.new inner) must be mentioned in the enclosing class.
Thanx
5. 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.

<BR>Contact Me<BR> <A HREF="mailto:basu_patel@usa.net" rel="nofollow">basu_patel@usa.net</A> <P>
Udayan Naik
Ranch Hand

Joined: Oct 18, 2000
Posts: 135
I think only E is correct in this case.
A)It must implement an interface. - FALSE. There is no such condition.
B)It is accessible from any other class. - FALSE.Not always.If we have a private non-static inner class then it is NOT accessible even if we do have an istance of the outer class available with us.
C)It can only be instantiated in the enclosing class - FALSE.It can be instantiated in any class if a reference to the enclosing class is available.It is true if we have a private non-static inner class , but that is not mentioned here.
D)It must be final if it is declared in a method scope. - FALSE.No such condition.
E)It can access private instance variables in the enclosing object. -TRUE.A non-static inner class can access private member variables of outer class.

------------------
Come on in !! Drinks are on the house in the Big Moose Saloon !!


Udayan Naik<BR>Sun Certified Programmer for the Java 2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem from sun sample