Objects: Characteristics
Learn about the two fundamental characteristics of an object, state and behavior, in this lesson.
We'll cover the following...
State and behavior
To understand object-oriented programming technology, we first need to understand objects. We have reproduced real-world objects’ behaviors and states in the programming world. Looking around helps to see how the real-world objects are moving around us. Humans, dogs, computers, cars, and many more.
Taking an in-depth look will give us more insights about objects. We find that real-world objects share two characteristics: they all have a state and behaviors. Humans have different states like name, height, emotion, etc. And they have behaviors, like shouting, walking, running, etc.
We are confident that each object has its own complexities and it varies. To start with, all we need to know is that there is a relation between an object and a class. To create an object, we need to write its states and behaviors inside a class. You can think of this as a blueprint.
Coding example: 6
In this example, we will deal with one object, a car. To make it simple, we keep two states: gear
and speed
. When ...