## Definition A unit of [[encapsulation|encapsulated]] data ([[attribute|attributes]]) and behaviour ([[method|methods]]). *Noun.* > `b` is an object created from the `BankAccount` class. ## Characteristics - Used in [[object-oriented programming]]; - is created using the [[constructor]] of its [[class]]; - has [[attribute|attributes]] with values stored in its own [[object state|state]]; and - can call [[method|methods]] of its class using dot notation, e.g., `object.method()`. ## Examples ### Lists Lists are objects with methods. ```python names = ["Justice", "Simon", "Ash"] # a list object, an instance of the built-in list class names.append("Shirley") # using the append method on the `names` list object ``` ### Objects made from custom classes `BankAccount` objects are [[instance|instances]] of the `BankAccount` class. ```python class BankAccount: def __init__(self, p_account_number): self.account_number = p_account_number self.balance = 0 b = BankAccount(12345) # a BankAccount object ``` ## Non-examples ### Class A class is the template from which objects are created and is not an object itself[^1]. ```python class BankAccount: def __init__(self, p_account_number): self.account_number = p_account_number self.balance = 0 ``` ### Primitive in a non-object-oriented language For example, an `int` in C is not an object. ```C int x = 5; // not an object ``` ## Notes [^1]: Actually, it is. See [[Python quirks#Everything is an object]].