What will be the output of this Java program?

Last Updated :
Discuss
Comments

What will be the output of this Java program?

Java
public class Demo {
    public static void main(String[] args) {
        int x = 10;
        {
            int x = 20;
            System.out.println(x);
        }
    }
}


20

10

Compilation Error


Runtime Error


Share your thoughts in the comments