File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interesting question from javacross! 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 "Interesting question from javacross!" Watch "Interesting question from javacross!" New topic
Author

Interesting question from javacross!

Noel Hinders
Ranch Hand

Joined: Jan 13, 2001
Posts: 44
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

Joined: Feb 01, 2001
Posts: 130
Option b. A member inner class is correct. That is the one which satisfies all the requirements!!

Sun Certified Programmer for Java 2 Platform
Noel Hinders
Ranch Hand

Joined: Jan 13, 2001
Posts: 44
Hi can anyone explain me the solution.
Thanks in advance.
Noel
Ishaan Mohan
Ranch Hand

Joined: Jan 20, 2001
Posts: 115
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
 
subject: Interesting question from javacross!
 
Similar Threads
Are static nested classes related to outer?
Inner class doubt ?
any difference between inner class and nested class?
When is an anonymous inner class NOT an inner class? Always?
inner class & nested class?