This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
compiles successfully produces the output: 0 0 3 0
I am totally puzzled about it.
As per my understanding...In the first loop values of i is set to 1,2,3,and 4. Therefore it tries to access these the positions: arr,arr,arrand arr. But when it tries to access arr it should throw ArrayIndexOutOfBoundsException because arr has only 4 elements.
Even if it could access them, the output should have been 0 0 0 0 and not 0 0 3 0 as they all are being set to 0 in the 1st loop. From where does that 3 persists?