• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Valiveru Mock Exam Question :Question 34.

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic