State & Behavior
State — What the Object Knows
State is the data an object holds right now. A lightbulb's state at this moment might be: isOn = false, brightness = 75%. State can change over time as the object is used.
Every object of the same class has its own copy. Bulb A can be on at 90% while Bulb B is off — they share the same class, but each has independent state.
Behavior — What the Object Does
Behavior is what an object can do — and most methods do their work by reading or changing the object's state. turnOn() changes isOn to true. brighten() increases the brightness value.
Think of state as the noun and behavior as the verb. The object is the complete sentence.
See It Live — The LightBulb Object
Click each method button on the left. Watch how calling a method changes the state fields — and how those state values then drive what the bulb looks like.
The method itself is just logic — the state is what persists.
Reading the Code
Notice how the fields at the top are just data — no logic. And the methods below only exist to read or update those fields. That separation is the pattern.
The One-Line Takeaway
Fields = the nouns (what it knows). Methods = the verbs (what it does). Together they make a complete, living object.