next up previous contents
Next: Sample Class Definition Up: The Characteristics of an Previous: What is An Object?   Contents

Abstraction

Abstraction is the specification of an abstract data type and includes a specification of the type's data representation and behaviour. It shows, what kind of data can be held in the new type of data, and all ways of manipulation of that data. An abstract data type is not intrinsic to the language, so compiler knows nothing about how to manipulate it until it is specified by the programmer in an appropriate manner.

JAVA programmers define the data representation and the behaviour of a new type (present the specification to the compiler) using the keyword class. It means, the keyword class is used to convert the specification of a new type into something that the compiler can understand and work with.

Once the new type is defined, one or more objects of that type can be put into existing state, from abstraction to reality. In other words, object of such kind can be instantiated.

Once instantiated, the object is said to have state and behaviour. The state of an object is determined by the current values of its data (instance variables) and the behaviour of an object is determined by its methods (member functions or instance methods).

The most popular example is a button, as an element of a GUI. If a button is viewed as an object, we can visualised its state and behaviour easily. It has a number of different states like size, position, caption, etc. Each of these states is determined by data stored in the instance variables of the button object at any given point in time. The combination of one or more instance variables for the particular state of the object named a property of the object.

Similarly, when you click it with a mouse, that usually causes some action defined for the button.

Each individual button object has instance variables, the values of which define the state of the button at any given time, from one side, and has certain fundamental behaviour to respond to a click etc to use with some action.


next up previous contents
Next: Sample Class Definition Up: The Characteristics of an Previous: What is An Object?   Contents
Olexiy Ye. Tykhomyrov 2001-12-16