Wednesday 6 December 2006

SCJP Chapter 3

A lot of information in this one, a 'foundation' chapter indeed.

Starting off with a look into assigning primitives and object references, which then necessitates casting types to the correct one. Implicit casts are done when there is no loss of data, conversely explicit casts are needed when data is at risk of being truncated.

A brief explanation on scope and lifetimes of variables followed by default initialization of instance and local variables. Watch out for shadow variables that exist in their own scope and override any other mimics.

Arrays: declaration, construction and initialization. 1-D, 2-D or n-D; a lot of logic needed for this one.

Wrapper classes for the primitives, enabling them to used as objects. Autoboxing is a new feature in Java 1.5, and is involved when overloading methods with wrappers. Overload paths - widening, autoboxing and var-args, in that order. Beware combination questions.

Lastly is garbage collection. Once an object has no references to it, it is ripe for collection. A request for garbage collection may be made but execution is not guaranteed. Similarly, the finalize method is also not guaranteed. If finalize runs, it does so only once for an object and may save the object from deletion.

Onto chapter 4!

No comments: