This is basic question but still i don\'t understand encapsulation concept . I did\'t understand how can we change the properties of class from other class.because whenever
Do you mean to say that the value of empid should be 10 and empname tom instead of 0 and null, if yes then-:
1)memory to the variables is allocated at run time , and also deallocated after the program is terminated.
2)Hence if you think that once if you give 10 to empid it should always be 10, it is not so , because empid is just a reference to a memory which is storing "10".
3)So by deallocation , i mean that empid is no longer pointing to memory area storing 10, after the program terminates
4)whenever you execute a new program , the empid is now pointing to other memory area , and that memory is allocated the the default value according t the respective datatype,in case of static variable. hence always 0 and null.