class="java类衍生" name="code">//: Cartoon.java //Constructor calls during inheritance class Art { Art() { System.out.println("Art constructor"); } } class Drawing extends Art { Drawing() { System.out.println("Drawing constructor"); } } public class Cartoon extends Drawing { Cartoon() { System.out.println("Cartoon constructor"); } public static void main(String[] args) { Cartoon x = new Cartoon(); } } // /:~
?java 类
输出结果:
Art constructor
Drawing constructor
Cartoon constructor