This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Top-Level class

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) What is a top level class ? Can top level class be declared protected/private ?
--cheers
Aarti
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Top Level class is any normal Java class, it can only be declared public or default (aka package).
like this:
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Definition: A nested class is any class whose declaration occurs within the body of another class or interface.
Definition: A top level class is a class that is not a nested class.
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy -- just wanted to add that there *is* some confusion (some of which I am responsible for) about the terminology because the JLS and Gosling's "The Java Programming Language" conflict. Gosling mentions that a static nested class is also known as a "Top Level Nested Class", but as Marlene pointed out , the spec clearly says that in order to be a Top Level class the class must NOT be nested. So, two documents Gosling has authored conflict with each another.
That's one of the few little 'issues' we have at Sun, because we're allowed to use just about anything Gosling says for the exam, as opposed to JUST the JLS, even though 90% of the exam wording now reflects the specification. The SCJP is also supposed to be about certifying working programmers, so we try to strike a balance between formal specification language and 'common use', as long as 'common use' isn't completely wrong or misleading. Well, in this case, many of us at Sun have been using the phrase "top level nested class" long enough ot have it burned into our heads. I'm in the process of removing it from mine right now. Ouch!
It used to be worse... the SCJP used to use the phrase "static inner class". Yikes! That was *never* correct, but in casual language, that's how we often talked about it.
I'm trying to work out if there are any other issues like that -- where there's a conflict between the spec and other Sun documents that might be used when we build the exam. I haven't found any that matter. And in fact, even this "top-level/static/nested" terminology won't hurt you on the exam. As long as you can identify in code exactly how they work, you won't be tripped up by what they're called.
Cheers!
Kathy
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kathy, thank you for sharing in detail your insider's view.
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have noticed in books and in forum discussions, some people use the word "visible" when they mean "accessible". The JLS has two definitions, one for accessible, another for visible.
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kathy, if the exams use definitions different from the JLS for top-level, nested, inner and static classes, I request that the terms and their meanings be published with the Objectives.
 
machines help you to do more, but experience less. Experience this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!