new一个类时,应该调它的构造方法,但下面的程序没有调,请高手解释一下。
public class T{
public static void main(String args[]){
T1 t1 = new Impl2();//这个地方为什么不写T1 t1 = new T1();它不是应该调T1的构造方法吗?
T t = new T();
t.t1(t1);
}
public void t1(T1 t){
String s = t.writeZy("");
System.out.println(s);
}
}
abstract class P implements T1{
private int conn(){
return 5;
}
}
class Impl extends P {
public String writeZy(String tm){
return "My Impl";
}
public void a(){
System.out.println("aaaaaaaaaaaa");
}
}
class Impl2 extends P{
public String writeZy(String tm){
return "My Impl222";
}
}
interface T1{
public static final int A_HEIGHT = 10;
String writeZy(String tm);
}
interface T2{
public void a();
}