Skip to main content

Define object; method implements behavior

Short answer

An object is an entity with identity, state (attributes), and behavior (operations). Behavior defines what an object can do; a method is the actual code implementing that operation, changing state or returning values. Without a method, an operation remains a declaration; a method thus justifies behavior by providing the concrete implementation.

Define Object with example. A method implements the behavior of object. Justify.

Object

An object is an entity of the problem domain that has identity, state and behaviour. It is an instance of a class. A student, a bank account, a book or a car are objects.

Example: Object acc1 of class Account

  • Identity: acc1 (distinct from acc2)
  • State (attributes): accNo = 1001, balance = 5000
  • Behaviour (operations): deposit(), withdraw(), getBalance()
 +-----------------------+
 | acc1 : Account        |
 |-----------------------|
 | accNo = 1001          |   state
 | balance = 5000        |
 |-----------------------|
 | deposit(), withdraw() |   behaviour
 +-----------------------+

A method implements the behaviour of an object

Behaviour is how an object acts and reacts, in terms of state change and message passing. It is the what an object can do, decided in analysis as an operation (e.g. "an account can be withdrawn from"). A method is the actual code that carries out that operation inside the class.

Justification:

  1. Every behaviour (operation) of an object needs a concrete body that changes the state or returns a value; that body is the method.
  2. When another object sends a message acc1.withdraw(500), it is the method withdraw that runs, checks balance >= 500 and reduces balance. This is the observable behaviour.
  3. Without the method, an operation is only a declaration with no effect.
  4. Different classes may implement the same operation by different methods (polymorphism), which gives different behaviour for the same message.

So behaviour is the abstract responsibility and the method is its implementation.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Object Oriented Analysis and Design chapter 1 questions →