Friday Java Quiz: Shadowing A Variable Name
I haven't posted a quiz for 34 days. It's time to have one.
Q: Will the following code compile and run without exceptions under the ? If so, what will it print?
1 public class Foo { 2 public static void main(String[] args) { 3 int x = 1024; 4 { 5 int x = 2048; 6 System.out.println("In inner block, x = " + x); 7 } 8 System.out.println("In outer scope, x = " + x); 9 } 10 }