prabal nandi wrote:Thanks a lot Jim for the explaination.. Another question related to same.
When 2 objects extending same class (method codes are shared) are accessing same method; how will JVM decide the service? Because we haven't explicitly declared the method as synchronized.
Whether or not this even could be a problem will depend on whether or not you are using multiple threads in your program, and running on a multi-core machine. If you aren't using multiple threads, or are on a single-core machine, then only one thing is running at any one time. The OS (and the underlying hardware) will make sure that you are not going to run into problems.
On a multi-core processor running multiple threads, there is still an easy answer for the code-- the code is simply copied from one core to the other. So you may have two instances of the code running at the same time. But the code is immutable, so there is no problem with synchronization. Since the code is the same everywhere, it doesn't matter how many copies you have.