Execution of Java static blocks in subclasses

前端 未结 2 1018
感情败类
感情败类 2021-01-12 17:18

I am preparing myself for Java certification test and I have found an interesting question related to the execution of Java static blocks. I have spent a lot of time reading

2条回答
  •  时光取名叫无心
    2021-01-12 17:44

    In this case, Child.age is equivalent to Parent.age. JRE will treat it as Parent.age, that's why only Parent is statically initialized, and Child's static initializer is skipped.

提交回复
热议问题