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.


Part I: Object-Oriented Programming

Encapsulation

Polymorphism

Inheritance

Part II: Linear Structures

Stacks and Queues

Array-Based Structures

Linked Structures

Part III: Algorithms

Analysis of Algorithms

Searching and Sorting

Recursion

Part IV: Trees and Sets

Trees

Sets

Part V: Advanced Topics

Advanced Linear Structures

Strings

Advanced Trees

Graphs

Memory Management

Out to the Disk

Part VI: Appendices

A. Review of Java

B. Unified Modeling Language

C. Summation Formulae

D. Further Reading

Index



Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
ISBN: 0131469142
EAN: 2147483647
Year: 2004
Pages: 216
Authors: Peter Drake

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net