1.
1 class Some { 2 static{ 3 System.out.println("1"); 4 } 5 6 public Some(){ 7 System.out.println("2"); 8 } 9 } 10 11 class Some2 extends Some{ 12 static{ 13 System.out.println("a"); 14 } 15 16 public Some2(){ 17 System.out.println("b"); 18 } 19 }
2.
public static void main(String[] args) throws Exception { // new Some2(); //1a2b // new Some(); new Some2(); 12a2b // Class.forName("com.gl.typeof.Some2"); //1a // Class.forName("com.gl.typeof.Some2"); new Some2(); // 1a2b // Class.forName("com.gl.typeof.Some2").newInstance(); //1a2b }