What is the order of the Constructors in this Java Code?

后端 未结 5 1002
夕颜
夕颜 2021-01-12 18:36

Here is the code, I defined two class named Father and Son, and create them in the main function:

public class Test {
    public static void main(String[] ar         


        
5条回答
  •  旧时难觅i
    2021-01-12 19:18

    Father() is called before Son(). The superclasses default constructor is implicitely called, we don't need a super() statement here.

    And who() inside the constructor of Father() calls the overriding method.

提交回复
热议问题