We began our presentation of class and objects in
Chapter 3 with descriptions
of the following essential elements:
- A Class definition
describes the attributes of a new data type that is implemented
at the source code level.
- The basic parts of class definition are its
- The instantiation process,
also referred to as the creation of an object, provides memory
for the data fields and assigns to that data a unique identification.
This unique set of data represents a single instance of the class.
- An object is accessed via a reference
variable. The data is accessed and methods are invoked via
the dot "."
operator.
- When a object's method is invoked, its data is used with the
method code. When the same method for another object of the same
class is invoked, then that object's data is used with the code.
- The static modifer means
that a data field or a method can be used even if no instance
of that class is instantiated. Only one memory location is assigned
to a static data field.
- Overloading allows
for methods with the same name but different argument lists.
Chapter 4 then describes how a class can be built upon to create
new classes:
- Inheritance allows a new class
to incorporated the code from another class and to create additional
data fields and methods.
- Overrriding of a method allows
for a new definition of a method from that in the super
class.
- An abstract class provides the essential
description of a general type but subclasses must add the data
and methods that describe specific types.
- Polymorphism
allows subclass instances to be treated as instances of a base
class. This is a very powerful generalisation technique that we
will use frequently.
- All Java classes extend the Object
class so all objects can be treated as instances of Object.
- In Java an interface is a completely
abstract class that allows for multiple implementations.
If you find that object oriented programming (OOP) remains somewhat
vague, your understanding of the concepts involved will deepen as
you see and use OOP techniques in coming chapters as we apply OOP
to graphics, threading, I/O, and other areas.
We return to class structure, design, and analysis in Chapter
16 where we give a brief overview of the Unified Modeling Language
(UML). UML provides a systematic approach to the design of classes
and to analysis of the interactions among objects. We then use UML
to design a set of classes for a distributed computing example.
References & Web Resources
Latest update: Oct.20, 2004
|