• 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

Inner classes and 1.4 exam

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
It seems that inner classes are heavily used for GUI applications and event handling. Since AWT is not a part of the 1.4 exam, to what extent do we need to know about inner classes for the 1.4 exam?
Thanks.
Mansi
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This link should help u..
Onwards
BbB
[ October 24, 2002: Message edited by: Bharathi Balu ]
 
Mansi Dave
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused.... With reference to inner classes the objectives for the 1.4 exams states that we need to know the following:
"Write code to construct instances of any concrete class including normal top level classes and nested classes."
There is no mention of anonymous inner classes or static inner classes in the objectives.
But Kathy said that anonymous inner classes come up everywhere in the exam? I'm not sure how to inerepret what is stated in the objective. Please help....

Mansi
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy,
OK, I *think* I can clear this up --
First, we're trying to use the term 'nested' instead of 'inner' (but I'll *never* get out of the habit of saying, "inner"), and it's acceptable to use it when referring to anything other than a static nested class.
There are TWO kinds of nested classes:
1) static (also known as "top level nested class" or even "top-level inner class")
2) not static
Although there are static nested classes on the exam, the exam makes extensive use of type 2 -- non-static nested classes (what we normally think of as "inner" classes). This type comes in multiple flavors:
* Member (defined inside the outer class, but not inside a method)
* Method-local
Within a method, the inner (oops, NESTED ) classes can be defined in:
* the method itself
* as an argument to a method
Within the method itself, the nested class can just be declared like a member nested class (except you can't put an access modifier on the method-local nested class, and it can't use non-final local variables).
OR... it can be an anonymous class, which means you're creating an instance of a type, and all you know is the TYPE -- not the name -- of the class.
These anonymous classes can be defined as arguments to a method, or just somewhere inside the method.
The wierd-looking part is that you can define the anonymous class as either a subclass of the class type you specify, or as an implementation class of the interface type you specify. The compiler figures it out. So it *looks* like you're trying to instantiate an interface, but you're not.
Anyway, they're used EVERYWHERE in the exam, but mostly in the Thread questions (having nothing to do with threads, but they're just a convenient way to build a new Runnable implementation in a very short space). So even though in the real world you would be much more cautious about using them, they're all over the exam as a way to save space, among other things (those other things include, of course, making it just a teeny bit more challenging
But... as long as you don't get thrown off by looking at them, you'll be just fine.
SO... bottom line:
ANYTHING that could possibly be related to a nested class will be in the exam. So we don't specify "anonymous" in the objectives, but "anonymous" is just one particular flavor of "nested class", so it's included.
Whew! Does that help?
Please ask away if it didn't !
-kathy
 
Mansi Dave
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your help Kathy. Your reply was very informative. Thank you for taking the time to clarify this.
Mansi
 
reply
    Bookmark Topic Watch Topic
  • New Topic