kids encyclopedia robot

Object (computer science) facts for kids

Kids Encyclopedia Facts

In Object-oriented programming, an object is an instance of a Class. Objects are an abstraction. They hold both data, and ways to manipulate the data. The data is usually not visible outside the object. It can only be changed by using a well-specified mechanism (usually called interface).

Suppose there is a bank account; this bank account has a current balance, but it also has a history of things that were done. These fields are however not directly accessible. There are methods like deposit() and withdraw() and checkBalance(). Most applications (and other objects) only change this object through this interface.

Banks usually impose a credit limit. Suppose, there are 1000 dollars on the account. If the client does not have a special agreement with the bank, he cannot take out more money than there is on the account; so he can withdraw() a maximum of 1000 dollars. He might have an agreement with the bank, so he can borrow money from the bank (but has to pay a fee). In that case, he might be able to withdraw 1500 dollars (or 2000 dollars). So the withdraw method has to do a lot of checks as described above. The account manager might see the account differently, she might have methods to set the maximum amount that can be taken out of the account, or to set the fee or interest rate that the customer has to be pay for the money borrowed.

As an object is an instance of a class; it has certain things from that class. It can perhaps be compared to other objects of that class. Two apples, one red and bigger, the other green and smaller. On the other hand: It is not that easy to compare different objects. A green apple does not have much in common with a steel wrench.

Related pages

See also

Kids robot.svg In Spanish: Objeto (programación) para niños

kids search engine
Object (computer science) Facts for Kids. Kiddle Encyclopedia.