Book Review: Ground-Up Java by Philip Heller - Part 2: Introduction to Object-Oriented Programming
(Page 3 of 5 )
Chapters 7 through 11 introduce the concepts of object-oriented programming, so here’s where you’ll meet such fashionable terms as
inheritance, construction, overriding, overloading and
polymorphism. The book explains the idea of data hiding and shows how a Java program can be structured into packages. It also shows how interfaces are useful in an OO language without multiple inheritance.
Chapter 11 covers a topic that is probably too often overlooked - exceptions. The principles of the topic are particularly well explained. However, I have one minor gripe on the accuracy of the text. Heller states ‘All exception subclasses in the core Java packages have two forms of constructors: a no-arguments version, and a version that takes a text message as an argument.’ Although this was true up until Java 1.3, Java 1.4 added two more constructors to the Exception class. There is now a constructor that accepts a Throwable as the cause of the Exception, and another that accepts both a message String and a Throwable cause. (Compare Sun’s JavaDoc for the Exception class in Java 1.3 with that for Java 1.4.) The advantage of these two new constructors is that you can partially deal with an Exception, and then re-throw it, if necessary constructing a different Exception class when you re-throw it.
For example,
try
{
oldMotherHubbard.getBoneFrom(cupboard);
} catch (BareCupboardException bce) {
String msg = bce.getMessage();
System.out.println(“Bare Cupboard Exception: “+msg);
throw new ResourceNotFoundException(msg, bce);
}
Next: Part 3: Core Java Packages and Using Java in Practice >>
More Reviews Articles
More By Simon White