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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner classes" Watch "inner classes" New topic
Author

inner classes

prakash pai
Greenhorn

Joined: Apr 06, 2007
Posts: 10
What is true about inner classes?
A) inner class can only be instantiated in its outer class.
B) Inner class be protected or private
C) Anonymous inner class can be both an explicit subclass and implements an interface
D) Anonymous inner class declare and instantiated at same place.
E) An instance of anonymous inner class can only be created in its outer class.
I marked D and E. But mock test gives B and D.
Could some one please explain why B is correct and not E.
Thanks in advance
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
It is clearly mentioned in JLS that private ,protected,static access modifiers are available for Inner class only
thus B is correct
Regarding e
Annonymous class are instaniated at the same time when they
are created and language of e says that it is the only way to create anonymous class thats why it is incorrect
hope it helps

SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Marcela Blei
Ranch Hand

Joined: Jun 28, 2000
Posts: 477
Originally posted by Gaurav Chikara:
Regarding e
Annonymous class are instaniated at the same time when they
are created and language of e says that it is the only way to create anonymous class thats why it is incorrect
hope it helps

I think e) is correct exactly beware that Annonymous classes are instaniated at the same time when they are created and they are created in an Outer class so...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inner classes
 
Similar Threads
4 questions from valiveru mock test
Valiveru Mock Exam Question :Question 34.
Reg. Inner classes : Valiveru's exam
Inner class mult choice
Inner Classes.