Class 1, Part 2 |
Intro to Java 30-IT-396 |
|
So, what is an object?
-
In general, an object is a model of a real-life noun.
-
It has the attributes that represent the attributes of that noun.
-
It also has the methods that operate on those attributes.
-
Objects interact with each other, but they should never directly change
the attributes of another object.
-
Instead, one object can be given access to another object, and can call
methods on that object that do the work.
-
Encapsulation is the art of putting data (attributes) in an object,
restricting access so that only that object itself can alter the data,
and then making methods, if necessary, to change that data.
-
This gives you much more control over the data. For example, you
could put validation routines in the method, change other attributes based
on the data received in the method call, and more.
-
This simplifies debugging dramatically!
Important Class Terms


Created by: Brandan
Jones January 4, 2002