GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Valiveru Mock Exam Question :Question 34. 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 "Valiveru Mock Exam Question :Question 34." Watch "Valiveru Mock Exam Question :Question 34." New topic
Author

Valiveru Mock Exam Question :Question 34.

Rosemol Thanjappan
Ranch Hand

Joined: Aug 08, 2000
Posts: 40
Hi all ,
This question is from another post.There is a discussion for this question
http://www.javaranch.com/ubb/Forum24/HTML/006450.html[/url]
Valiveru Mock Exam Question :
Question 34.
Which of the following are true about inner classes

A. Inner classes can only be instantiated in its outer class
B. Inner classes can be protected or private
C. Anonymous inner class can be both an explicit subclass
and implements an interface.
D. Anonymous inner classes declare and instantiated at the
same place.
E. An inner class can be static only when it's outer class
is static.
F. An instance of an Anonymous inner class can only be
created in it's outer class
They said B and D but I chose F as well.

The following post makes sense.

quote:
--------------------------------------------------------------------------------
Originally posted by Sahir Shah:
1. "An instance of an anonymous or local inner class can only be created within the scope of its declaration "
This statement is true.
2. "An instance of an anonymous or local inner class is accessible only within the scope of its declaration "
This statement is false.
Creating an object is not the same as passing a reference to an object around.
--------------------------------------------------------------------------------

Can any moderators confirm this?
Thanking you Rosemol.
natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
Eventhough u cannot instantiate an anony.in.class outside its outer class, you can get a reference to it anywhere using the superclas it inherits or its outerclass method.
Refer KAM, there is a very good code for getting references.

Sun Certified Programmer for Java 2 Platform
 
GeeCON Prague 2014
 
subject: Valiveru Mock Exam Question :Question 34.