Polymorphism
This chapter discusses polymorphism, the second principle of object-oriented programming. Polymorphism is the ability for a word or symbol to mean different things in different contexts.
In Section 2.1, we explore references. References allow for polymorphic typesthat is, types of variables which can hold more than one kind of value. In the context of checking for equality of such variables, we introduce the Object type, which can hold almost anything. Some details about primitive types and Strings are also pointed out.
Arrays are particularly interesting reference types. Section 2.2 deals with arrays, including multidimensional arrays. The game of Domineering is presented as an example.
Interfaces, which specify the behavior of a class without getting into the details of its implementation, are covered in Section 2.3. An interface is also a polymorphic type.
Section 2.4 discusses overloading, the ability of a method name to mean different things depending on the types of its arguments.