Hi guys! I've just implemented this code in java 8 and the correct answer is letter F. I didn't have any compilation fail. I guess in Java 6 is the same.
Thanks. :)
That is actually a new thing in Java 8. Take a look at what the Oracle docs say about this:
So, since Java 8, the variable could be "final or effectively final". They define the idea of "effectively final" as "A variable or parameter whose value is never changed after it is initialized is effectively final.".
Since the deck1 variable does not actually get changed in this program, Java 8 can recognize that as an effectively final variable, and proceed with compilation.