title: Memory Allocation for objects in java
body: <p>I am a beginner in Java and I had completed C++.
  <strong>In C++,the memory allocation for member functions is done at the time they are declared as a part of a class and not when the objects are created,when the objects are created,then only the memory allocation for the instance variables is done,that is for every object memory allocation for instance variable is done seperately and the member functions are shared commonly by all the objects.
  In case of instance variables,I know the same case happens in java,but what happens in case of member functions?</strong></p>
  
  <p>In C++;
  For e.g. if we have 2 instance variables a and b,and we had created 3 objects x,y,z and let us say we have a member function getData(),
  then all the 3 objects have a seperate copy of the two instance variables a and b,but share a common copy of getData().</p>
  
  <p>For instance variables,same is the case in java,but what for member functions?</p>