File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem from sun sample

 
Basu Patel
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Udayan Naik
Ranch Hand
Posts: 135
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic