Objects and Classes
Introduction
OOP Programming Concepts
Object-oriented programming (OOP) involves programming using objects. An object represents an entity in the real world that can be distinctly identified. For example, a student, a desk, a circle, a button, and even a loan can all be viewed as objects. An object has a unique identity, state, and behaviors. The state of an object consists of a set of data fields (also known as properties) with their current values. The behavior of an object is defined by a set of methods.
An object has both a state and behavior. The state defines the object, and the behavior defines what the object does.
Classes are constructs that define objects of the same type. A Java class uses variables to define data fields and methods to define behaviors. Additionally, a class provides a special type of methods, known as constructors, which are invoked to construct objects from the class.
Simplified methodology
- Write down detailed description of problem
- Identify all (relevant) nouns and verbs
- From list of nouns, select objects
- Identify data components of each object
- From list of verbs, select operations