class A{
int a;
int b;
void method()
{
}
}
Now when we create 2 objects for class A as A a1,a2;a1.a and a2.a will not share memory space as they are supposed to have unique values.But the memory space for method() is being shared by 2 objects a1 and a2.
A very important feature of OOPs is encapsulation which is generally done by making variables as private and the function as public so that no one can access the variables directly like A.a or A.b
Access to these variables should be strictly through the method.




