Charles, What about the overriding feature and super class and child class relationship in these methods and about run time polymorphism? Is this going out of the exam much?!! [ May 10, 2006: Message edited by: Shaliey Gowtham ]
Hi Mathias De Groof, Welcome to JavaRanch. Nice to point out the variables uninitialized. But choice 1 is correct as there can be only one thread executing one synchronized block to the fullest on an instance(Object has only one lock);
i.e when one thread has entered a synchronized method in a class for a particular object no other thread can execute any other synchronized methods for that particular object in reference to non-static methods
Choice 3 is incorrect because many threads can access the method c() as its not synchronized(i.e. two threads might have incremented the k.v but none has decremented k.v, thus k.v > 1); Choice 4 is incorrect since when the method c() alone is called then k.v > j.v; Choice 5 is incorrect because in method b(), j.inc() is called before k.inc() so in this condition j.v > k.v
[ May 10, 2006: Message edited by: Shaliey Gowtham ]
When the class is not visible, then none of its members are visible. But we have the member methods to be public because mostly all the classes implement interfaces and we are forced to have the methods to be public.
Further in future when the class is made visible outside we need not change the API.