Objects Characteristics

Each and every object have following characteristics

  • Identity
    Identity makes the object unique from other objects
  • State
    State of the object is nothing but the attributes of the object, and they may change during execution of program
  • Behavior
    It is defined by the functions/methods that object provides
For example assume we have a object ‘Benz’ for class ‘car’ the characteristics are defined as
  • Identity : Object name ‘Benz’
  • State: Color, model number, gears, price etc
  • Behavior: drive(), getPetrol()
Base Class ‘Car’
Class Example
Creating Object ‘Benz’ for Class ‘Car’
object examplePoints to observe
  • Here new instance of class ‘car’ is created inside another Test_class  as ‘Benz’ which is called object
  • All the variables(isTankEmpty) and the methods(getPetrol() ) of class ‘car’ are only accessed by the objects created for that class.
Conclusions
  • Objects have Identity, State, Behavior
  • All the methods/Variables of a class  can be accessed only through the object created for that class.