7: Polymorphism | CodeGuru

7: Polymorphism

Bruce Eckel’s Thinking in Java Contents | Prev | Next Polymorphism is the third essential feature of an object-oriented programming language, after data abstraction and inheritance. It provides another dimension of separation of interface from implementation, to decouple what from how. Polymorphism allows improved code organization and readability as well as the creation of extensible […]

Written By
CodeGuru Staff
CodeGuru Staff
Mar 1, 2001
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Polymorphism


is the third essential feature of an object-oriented programming language,


after data abstraction and inheritance.

It


provides another dimension of separation of interface from implementation, to


decouple


what

from


how

.


Polymorphism allows improved code organization and readability as well as the


creation of


extensible

programs that can be “grown” not only during the original creation


of the project but also when new features are desired.

Encapsulation


creates new data types by combining characteristics and behaviors.


Implementation hiding separates the interface from the implementation by making


the details


private

.


This sort of mechanical organization makes ready sense to someone with a


procedural programming background. But polymorphism deals with

decoupling
in terms of
types.
In the last chapter, you saw how
inheritance
allows the treatment of an object as its own type
or
its base type. This ability is critical because it allows many types (derived
from the same base type) to be treated as if they were one type, and a single
piece of code to work on all those different types equally. The
polymorphic
method call allows one type to express its distinction from another, similar
type, as long as they’re both derived from the same base type. This
distinction is expressed through differences in behavior of the methods you can
call through the base class.

In


this chapter, you’ll learn about polymorphism (also called

dynamic
binding

or
late
binding

or
run-time
binding
)
starting
from the basics, with simple examples that strip away everything but the
polymorphic behavior of the program.
Contents

|

Prev

|

Next
CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.