• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Top-Level Classes

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The expression TOP-LEVEL CLASS is one that I have frequently come across in my studies for the SCJP, but my instructor at school has never used it. Can someone please clarify what the criteria for a class to be defined as TOP-LEVEL are. Thank You.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A very very short definition is "A Top-Level class is one that contains (a) nested class(es), and not a nested class itself." It is at the top of the nested class structure.
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Linde, in my understanding, Top-Level Class are those class that you can instantiate directly without the instance of other class. See the following code:

So, //0, //1, //2, //3, //4 and //5 are all Top-Level class(interface), among which //1, //2, //3, //4 are also called Top-Level nested class. Note that they can all instantiated without other class' instance.
Other than that, like class NotTLClass, are called inner class.
Hope it helps.

------------------
Guoqiao Sun
Sun Certified Programmer for Java™ 2 Platform
try my mock exam¹² at my homepage.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic