At first glance, Java and C++ appear very similar. Both languages use notation derived from the widely-used C programming language. Nevertheless, Java and C++ are radically different beneath the surface. Java is an object-oriented language: a program is simply a collection of classes and inheritance between classes is pervasive. In contrast, C++ is typically used as an object-based language where classes are simply used to encapsulate procedural code, hiding implementation details from the clients of the class code. Object-oriented programming in C++ is awkward for a variety of reasons that will become apparent as we explain object-oriented programming in Java.
In this short monograph, we will discover how easy it is to write object-oriented code in Java. Although it is tecnically possible to write object-based code in Java, it is considered very bad style. Fortunately, our pedagogy will prevent you from writing object-based code by deferring the discussion of the Java language features that support object-based programming.