//: 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(); } } ///:~
该程序的输出显示了自动调用:
Art constructor Drawing constructor Cartoon constructor