File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interesting question from javacross!

 
Noel Hinders
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
this is an interesting question from http://www.javacross.com simulation
An existing class JC now needs some additional functionality which it is proposed to add with a nested or inner class, NEC. You have been able to establish the following requirements
1. There will probably be more than one JC instance active in the appilcation so the solution has to work no matter how many JC instances are there
2. NEC will need to have access to instance methods and variables as well as static variables
3]. More than one method in JC will have to have access to a method of NEC
Which configuration of nested class is the best bet for the problem

a]. A static class
b]. A member inner class
c]. An inner class defined in a JC method
d]. An anonymous inner class
 
natarajan meghanathan
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option b. A member inner class is correct. That is the one which satisfies all the requirements!!
 
Noel Hinders
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi can anyone explain me the solution.
Thanks in advance.
Noel
 
Ishaan Mohan
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
a) If the inner class is static then NEC will not be able to access to instance methods and variables other then the Static ones.
c)& d) If the inner class is defined in a method or a annonymous then it can access only the final variables of the function, not all.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic