Saturday, December 22, 2007

Google Interview Question - Part 6

Continue with the question in the previous post:
http://j2ee-now.blogspot.com/2007/12/google-interview-questions-part-5.html

Here is the answer to the question,
If two threads would run in parallel and call this method with values 10 and 7,
The first thread would create the array with size 10 and then thread 2 would re-initialize the same static array with size 7, then the fist thread would run on the array from 0 to 9 and would put values inside however the array size is now 7 so on list[7] it would throw the exception.

No comments:

Links

 
RSS Feeds Submission Directory