• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Rule Round-up (#104)

 
Karin Paola Illuminate
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(#104) an inner class has free access to ALL member data of its enclosing (outer) class.
Answer: true
An inner class has a special relationship and can see even private member data of the outer class.
But, what about a static member class, which can only access static members? I answered false.

[ May 01, 2003: Message edited by: Karin Paola Illuminate ]
 
Lawrence Chettiar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karin,
If you see thru the JLS
"Inner classes may inherit static members that are not compile-time constants even though they may not declare them. Nested classes that are not inner classes may declare static members freely, in accordance with the usual rules of the Java programming language. Member interfaces (�8.5) are always implicitly static so they are never considered to be inner classes. "
Which clearly indicates that a static class is not a inner class. its a member class same as the interface defined within a class (member interface)

Hope this helped you.
Lawrence
 
Karin Paola Illuminate
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It is now clear to me that
Inner classes include non-static member classes, local classes and anonymous classes.

The definition of an inner class was not completely clear to me.
Inner Classes
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic