Originally posted by andy lau:
The answer is : 4. Why?
Well, the reason it could be one or the other is that you don't know for sure which
thread is going to get to use the processor when start is called. In one case, you could simply finish execution of main, printing out "vandeleur". On the other hand, if the new thread gets to use the processor right away, the run method may get executed, which changes the member variable sName. Then, when main is completed, "vandeleur 0 1 2 3" would be printed.
Actually, if you look closely at the answers, B and C can't possible be true - those cases could never happen. And, since there are no syntax errors, A is not correct, either. That only leaves you with choice D.
The answer is:1,2,3. Why?
When you declare and inner or nested class, you are free to use public private or static. Of course, if you use the keyword static, you have a nested class, not an inner class. The
word "friend", however, isn't a keyword in
Java - that's a C++ thing.
I hope that helps. If you have any more questions, just ask.
Corey