1) Compile time error 2) Compilation and output of "vandeleur wiggy" 3) Compilation and output of "vandeleur wiggy 0 1 2 3" 4) Compilation and output of either "vandeleur", "vandeleur 0", "vandeleur 0 1" "vandaleur 0 1 2" or "vandaleur 0 1 2 3"
The answer is given as 4, but i dont really undersatnd how come wiggy is missing in the answer? where has it gone to??
This question is pretty straight forward and is based on Shadowing concept...I think! I dont find the question of threads here. Are you meaning two threeads as one main thread and the thread t? please clarify..
Two things to consider here: 1- Shadowing the variable sName; 2- Two threads are working in the program i) main thread ii) thread t
The output of the program depends when does the line System.out.println(sName); of the main() get executed. If it is executed before loop starts, the output will be different, if it executed in between any cycle of the loop or after the loop completes, the output will be different.
Therefore no guaranteed output.
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad: