Introduction
In the first article of this series, we compared how Java and C++ support
various object-oriented concepts. In this second and final part, we cover
other programming language concepts and examine differences in how the two
languages support them. Each programming language concept has its own
section, first presenting the concept in commonly-used terms and then
comparing how ANSI C++ and Java 1.0 implement, or can be used to implement,
it.
Object and Class Initialization and Finalization
Objects and classes both need to be given the opportunity to initialize their
contents before they are used, and to clean up before they are destroyed. For
objects, this is typically done using constructors and destructors.
Because Java has garbage collection, destructors are not needed. However,
there is still the need to allow an object to be cleaned up before being
de... (more)