Class - Consider a Harmonium
Class Harmonium
{
public string color;
public int total_keys;
public string bellows;
public void Sound();
}
It is a blue print of newly created things that contains variables for storing data (characteristics) & functions (behavior) which is applied on that data.
Object
- It is a instance of class
- They are inherit from System.Object
- Object is an entity which has a well-defined structure & behavior.
Object has characteristics as :
- State
- Behavior
- Identity
- Responsibility
Example - a car, a person, hard disk, pen, bank account
1. State of an object
State of an object includes the current values of all its attributes.
An attribute can be static (values will not change) or dynamic (values will be change)
Consider a Employee has following attributes.
Static
- Empid
- Name static
- Gender
Dynamic
- Age
- Address
- Phone / mobile no dynamic
- Salary
- Education
2. Behavior of an object
Behavior is how an object acts & reacts, in terms of its state change and message passing.
Employee is an object ===> Calculate_salary, Emp_details
- The change in state of an object reflects in its behavior.
- In above example Calculate_Salary and Emp_Details are behaviors of an employee
3. Identity of an object
- Every object has its own identity.
- Property of an object which distinguishes it from all other objects is an Identity.
- Single or group of attributes can be identity of an object
Employee - Empid, Name, Gender, Mobile_No
4. Responsibility of an object
Responsibility of an object is the role it serves within the system.
Example - responsibility of an employee is to carry out the work given & get the salary
Abstraction


Join the conversation! Your thoughts help the community grow.