示例记录(三)
1、写出示例的执行结果
1 public class ClassA { 2 3 public ClassA(){ 4 System.out.println("Class-A"); 5 } 6 { 7 System.out.println("Class-A:{}"); 8 } 9 static { 10 System.out.println("ClassA:static"); 11 } 12 13 }
1 public class ClassB extends ClassA { 2 3 public ClassB(){ 4 System.out.println("Class-B"); 5 } 6 { 7 System.out.println("Class-B:{}"); 8 } 9 static { 10 System.out.println("ClassB:static"); 11 } 12 13 }
执行:new ClassB();
执行结果:
ClassA:static ClassB:static Class-A:{} Class-A Class-B:{} Class-B