• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Inner classes

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
13)
Which of the following statements is true?
a) An interface can contain a nested top-level inner class.
b) An interface can contain a member inner class.
c) A member inner class can implement an interface.
d) A static method can contain a local class.
e) A static method can contain a nested top-level class.
I think its c) and d).
Why not a) because interface conatains nested toplevel classes not nested top-level inner class.
Why not b) look above for a) expl..

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the answer is A, C, and D.
Can anyone else elaborate?
 
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the source says A is true, I would say it is badly worded. Taken as it is, I would say it's wrong: There is no such thing as a nested top-level inner class. It's either an inner class or a top-level class, not both.
You can, however, define a class as a member of an interface and the effect is the same as declaring a top-level class.
Check out the difference between the way you'd instantiate a class defined in an interface and the way you'd instantiate a true inner class:

[ February 01, 2002: Message edited by: Junilu Lacar ]
 
Junilu Lacar
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the where the JLS mentions Interface Member Types: http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html#252566

"Roll"
Please take a moment to review the JavaRanch Naming Policy. Please re-register using a Display Name that complies with the rules.
Thanks for your cooperation.
Junilu
 
Paul Salerno
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Junilu,
That was an old post I dug up whilst doing a search. Roll's probably not around any more
 
Junilu Lacar
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
darn itchy trigger finger...
If you promise to give fair warning when reviving old posts next time I'll promise to check the dates before unholstering my Naming Policy macro. Deal?
Junilu
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea, but he managed to post 61 times and still never changed his name! He was either really fast or the bartenders back then were really slow.

Rob
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The naming policy was instituted at a later date (about Jan 2001)
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so, what are the correct answers? Junilu Lacar, can you give a explanation about the each correct answer?
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what�s the difference between options A and B? isn�t a top-level nested class a member class?
Francisco
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no such thing as "a nested top-level inner class." If a class is inner it cannot be top level.
"a member inner class." The members of a class include fields, methods and other classes or interfaces declared within the body of the class. Also those inherited from other classes or interfaces are members.
 
reply
    Bookmark Topic Watch Topic
  • New Topic