State and Operations
In object-oriented programming, objects can represent actual objects in the real world, such as houses, students, fish, or clocks, or more abstract or computer-specific objects, such as lists, locations, or email messages.
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Class
State
properties / attributes
(generally private)
Operations (or Actions)
methods / functions
(generally public)![]()
color, owner, address paint(newColor), sellTo(newOwner), getColor(), getAddress() ![]()
size, color, location move(), getColor(), getLocation() ![]()
hour, minute, time zone set(hour, minute), changeTZ(newZone), getHour(), getMinute() "Hello!" string contents length(), equals(anotherString), contains(aSubString)
Big Questions:
- When using an object, how do we know what operations are available for it?
- Given a class, how do we construct (instantiate) objects and invoke their operations?
The answers to these are in future videos (Reading Class Documentation, and Primitive Types vs. Classes).