Given:
What is the result?
Given:
What is the result?
The code will fail to compile because the local variable 'y' defined in the enclosing scope must be final or effectively final to be accessed within the inner class. Since 'y' is being modified (decremented) within the inner class, it is not effectively final and this leads to a compilation error.
D. Local variable y defined in an enclosing scope must be final or effectively final
D is correct y-- modified variable so, y is not efectively final, then compilation error is thrown
java.lang.Error: Unresolved compilation problem: Local variable y defined in an enclosing scope must be final or effectively final D is correct
D correct local variable referenced in an inner class should be final or effectively final , here y is post decremented