• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

new bie question-- top-level classess

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am preapring for my SCJP exam. I have some good experience in c/c++. I started my prepration with RHE and side by side taking mock exams to my confidence level. I come across the words "top-level classes" and sometimes "top-level classes (not inner class)". Can someone explain what exactly a "top-level" class mean with respect to the package, inner classes, etc..
Thanks
Ramesh
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Ramesh:
Let me try it first. Correct me if I am wrong.
Top-leve classes: they are members of packages.
Nested top-level classes: Inner classes with static modifier.
A local classes: defined in a blocks.
Anonymous classes: combine delcare & creation, have no names.
Jane Z.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'RT'
PROPER NAMES ARE NOW REQUIRED!!
Read this post for more details.
Ajith
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to add to Jane's post, here's a code example

Hope that helps.
------------------
Jane
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jane Griscti:
[B]Just to add to Jane's post, here's a code example

[/B]


Jane, are you trying to depict an anonymous class? Is this right?
thanks,
Zulfiqar

 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Zulfiqar,
Yes. I was trying to show that you can create an Anonymous class using any existing class. For example, if you had a class named <code>Attr</code> that had a method <code>public Object setValue(Object nv)</code> you could create an Anonymous class based on <code>Attr</code> by doing something like:

You can call any of the original constructors but you can't redefine a constructor as technically the anonymous class doesn't have a name.

------------------
Jane
 
This tiny ad is guaranteed to be gluten free.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic