Classes, Methods, and Interfaces
Apress eBooks · 2006
As described in Chapter 2, a computer program, written in any programming language, is basically made of three elements: data, operations on data, and the logic that determines the operations. Chapter 2 discussed different types of data and the corresponding variables to handle the data. The smallest unit of a program that performs operations on data and holds the logic for these operations is called a function. In procedural languages such as C and Pascal, the data and functions are not closely bound together. The data flows in and out of the functions freely. This not only makes a program highly error prone but also increases its complexity. An object-oriented language, such as Java, offers the promise of binding the data and the operations on data (functions) together. In object-oriented terminology, functions are called methods. Therefore, in Java, the data and the methods that could operate on it are bound together into one entity, called a class. These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.