Multiple static blocks

Report a typo

Here's a class containing multiple static initialization blocks:

class InitBlock {

    static int field = 20;

    static {
        field = 30;
    }

    static {
        field = 40;
    }
}

What does the following code print?

System.out.println(InitBlock.field);
Enter a number
___

Create a free account to access the full topic