Introduction
- The key concept in object-oriented programming is the object:
- An object encapsulates:
- data (an objects's attributes)
- methods (an object's behaviors)
- Objects hide information about their implementation from their users:
- To use an object, we must interact with it according to its methods.
- We cannot (if it is designed properly) fiddle directly with its attributes.
- Users should not need to know how an object is implemented in order to use it.
- This is true of all the library methods that we have used.
- In C, the unit of programming is the function (method, in Java); the data which the function processes is
secondary.
- In Java, the unit of programming is the object, and programming is object-centered, giving appropriate attention
to both an object's attributes and its behaviors (i.e., its data and its methods).
- Java programmers focus on creating their own user-defined classes.
- A class's data elements are called its instance variables.
- Just as an instance of a primitive data type, such as int, is called a variable, an instance of a class is called an
object.